Lambda Posted January 1, 2017 Posted January 1, 2017 Hey there, so I'm trying to find a way to detect 2 quartz blocks and a gold block on top, on each side.. However, I don't know how to get started. I could do EnumFacing.Horizontals , however finding the two blocks above the block that is detected by the forloop is where I'm stuck.. What would be the best way for the TE to detect if there is a 3 high structure (with the top of them being gold blocks) on each side. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted January 1, 2017 Posted January 1, 2017 pos.offset(facing).up()? Quote 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.
Lambda Posted January 1, 2017 Author Posted January 1, 2017 How would I put all of this? Multiple for loops? 3 positions for different blocks? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted January 2, 2017 Posted January 2, 2017 Loop over the EnumFacing horizontal values. That's the "facing" in my code above. Quote 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.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 Would something like this work? public void lookForBlocks(){ for(EnumFacing facing : EnumFacing.HORIZONTALS) { BlockPos quartzPos = pos.offset(facing, 5); BlockPos quartzPosUp = pos.offset(facing, 5).up(); BlockPos goldPos = pos.offset(facing, 5).up(2); IBlockState quartz = world.getBlockState(quartzPos); IBlockState quartzTop = world.getBlockState(quartzPosUp); IBlockState gold = world.getBlockState(goldPos); if((quartz.getBlock()) == Blocks.QUARTZ_BLOCK && quartzTop.getBlock() == Blocks.QUARTZ_BLOCK){ if(gold.getBlock() == Blocks.GOLD_BLOCK) { } } } } Now how would I make sure all four sides are present? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 Check if one doesn't exist rather than if they all exist. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Draco18s Posted January 2, 2017 Posted January 2, 2017 That if statement will detect if that side is properly constructed. Check if one doesn't exist rather than if they all exist. You'll need a boolean and set the boolean to false if a side fails. Or you can use a counter to count successes and check if successes == 4. Quote 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.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 If i use a counter, then everytime the forloop runs, which is every tick, the counter will increase by one again and again even if one side is there. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 If i use a counter, then everytime the forloop runs, which is every tick, the counter will increase by one again and again even if one side is there. Think Local not global. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 It will still increment every tick Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
perromercenary00 Posted January 2, 2017 Posted January 2, 2017 i do something like this but was because i do some complicated things whit mi mod in that time all mi structures was designed to occupy only one chunk and set the block whit the tile entity at the center of the chunk at y=0 so just check if at the center of the chunk is one of mi structure blocks and then also have the facing for the structure but this obviously wont works for vanilla or other mods structures Quote
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 It will still increment every tick public void update() { structureCheck(); } public int structureCheck() { int structureCount = 0; for (int i = 0; i < 10; i++) { structureCount++; } return structureCount; } What is the value of structureCheck every time it is called? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 public void lookForBlocks(){ int count = 0; System.out.println(count); for(EnumFacing facing : EnumFacing.HORIZONTALS) { BlockPos quartzPos = pos.offset(facing, 5); BlockPos quartzPosUp = pos.offset(facing, 5).up(); BlockPos goldPos = pos.offset(facing, 5).up(2); IBlockState quartz = world.getBlockState(quartzPos); IBlockState quartzTop = world.getBlockState(quartzPosUp); IBlockState gold = world.getBlockState(goldPos); if((quartz.getBlock()) == Blocks.QUARTZ_BLOCK && quartzTop.getBlock() == Blocks.QUARTZ_BLOCK){ System.out.println(facing); if(gold.getBlock() == Blocks.GOLD_BLOCK) { System.out.println("structure on: " + facing + " is complete"); count++; } } } } well your example will always make count = 0, because your setting it to 0 every time the update is called. like in my, the count never increases, even it the println prints. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 That is because you are printing the count after setting it to 0... Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 Makes sense, now it works Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Lambda Posted January 2, 2017 Author Posted January 2, 2017 Is there a better way than this to iterate though nearby chunks than this? public List<Chunk> nearbyChunks(World world) { List<Chunk> list = new ArrayList<>(); list.add(world.getChunkFromChunkCoords(world.getChunkFromBlockCoords(pos).getPos().chunkXPos, world.getChunkFromBlockCoords(pos).getPos().chunkZPos)); list.add(world.getChunkFromChunkCoords(world.getChunkFromBlockCoords(pos).getPos().chunkXPos+1, world.getChunkFromBlockCoords(pos).getPos().chunkZPos+1)); list.add(world.getChunkFromChunkCoords(world.getChunkFromBlockCoords(pos).getPos().chunkXPos-1, world.getChunkFromBlockCoords(pos).getPos().chunkZPos-1)); list.add(world.getChunkFromChunkCoords(world.getChunkFromBlockCoords(pos).getPos().chunkXPos+1, world.getChunkFromBlockCoords(pos).getPos().chunkZPos-1)); list.add(world.getChunkFromChunkCoords(world.getChunkFromBlockCoords(pos).getPos().chunkXPos-1, world.getChunkFromBlockCoords(pos).getPos().chunkZPos+1)); return list; } Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 Why are you using World#getChunkFromChunkCoords and then to get the chunk coords you get the chunk from the block coords... Just use World#getChunkFromBlockCoords(BlockPos). Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 Well because I'm getting the ones one next to, because ChunkPos are like: 0,1 1,0, correct? So adding one the the chunkpos will just shift over / up / down instead of adding 16.. atleast that was my thought process Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 Well because I'm getting the ones one next to, because ChunkPos are like: 0,1 1,0, correct? So adding one the the chunkpos will just shift over / up / down instead of adding 16.. atleast that was my thought process Not quite adding 16, it is a bit shift. Tou are doing more processes the way you are doing it. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted January 2, 2017 Author Posted January 2, 2017 So what should I change it to? Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted January 2, 2017 Posted January 2, 2017 So what should I change it to? int xCoord = (getPos().getX() >> 4) + 1; int zCoord = (getPos().getZ() >> 4) + 1; worldObj.getChunkFromChunkCoords(xCoord, zCoord); This will get a chunk that is offset by one in the x and z (chunk)position. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
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.