December 1, 20168 yr Author I dont know why but the same code in Bukkit works very fine. But here...NOPE...So I think the probleme is in spawning the falling sand
December 1, 20168 yr Two things multiple blocks on the same x and z coord, and second how would I even find the correct y coord. Would it be at the highest possible y position there is a block or would it be at the first block with air above them. Hence using a Set<Pair> - just store one instance of each (X,Z) pair. But you're right - you'd need to store a Y-value as well; so perhaps a Map<Pair<Integer,Integer>, Integer> would be better, where the key is (X,Z) and the value is Y. As for which Y-value, that's up to the mod developer; the smallest Y would be a reasonable choice. Why not just create a list of BlockPos? It already stores x, y, z and it is given to you in that form? Or heck you could do a Map of <BlockPos, IBlockState> and then iterate through them and spawn them with that information. 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.
December 1, 20168 yr Why not just create a list of BlockPos? It already stores x, y, z and it is given to you in that form? Or heck you could do a Map of <BlockPos, IBlockState> and then iterate through them and spawn them with that information. Because you'll end up iterating multiple times up a column of blocks if you have 2 blocks with the same (X,Z) in the list of affected blocks. Waste of CPU cycles.
December 1, 20168 yr I dont know why but the same code in Bukkit works very fine. But here...NOPE...So I think the probleme is in spawning the falling sand Is your current code the same code that you last posted? Because as I and other have pointed out, it's wrong. (And spawning falling blocks via Bukkit ends up calling the same internal server code to create entities; the only difference is that Bukkit adds another layer of abstraction. So it's highly unlikely that Forge is failing to do something that Bukkit can do).
December 1, 20168 yr Why not just create a list of BlockPos? It already stores x, y, z and it is given to you in that form? Or heck you could do a Map of <BlockPos, IBlockState> and then iterate through them and spawn them with that information. Because you'll end up iterating multiple times up a column of blocks if you have 2 blocks with the same (X,Z) in the list of affected blocks. Waste of CPU cycles. Ok? but why is it a waste if he/she really wants all the blocks to become falling sand entities. Or did I miss the part where he/she said they want some. And if that is the case would it not be better to not use a method that creates a new Object with all of this data, and instead just go through it and gather and use the information you want. 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.
December 1, 20168 yr Why not just create a list of BlockPos? It already stores x, y, z and it is given to you in that form? Or heck you could do a Map of <BlockPos, IBlockState> and then iterate through them and spawn them with that information. Because you'll end up iterating multiple times up a column of blocks if you have 2 blocks with the same (X,Z) in the list of affected blocks. Waste of CPU cycles. No you wouldn't. By storing Y values you don't iterate over the columns. 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.
December 2, 20168 yr Why not just create a list of BlockPos? It already stores x, y, z and it is given to you in that form? Or heck you could do a Map of <BlockPos, IBlockState> and then iterate through them and spawn them with that information. Because you'll end up iterating multiple times up a column of blocks if you have 2 blocks with the same (X,Z) in the list of affected blocks. Waste of CPU cycles. No you wouldn't. By storing Y values you don't iterate over the columns. Looking at the OP's code, the intention appears to be to iterate upward from each affected block to max world height, turning every block into a falling block; presumably the intention is for underground explosions to cause cave-ins. So upwards iteration is in fact required. What should be avoided is doing that iteration more than once for each column of blocks.
December 2, 20168 yr Author Here is the Code in Bukkit: @EventHandler public void onExplode(EntityExplodeEvent e){ fall(e); } @SuppressWarnings("deprecation") private void fall(EntityExplodeEvent e){ List<Block> list = getBlocksToFall(e); World w = e.getEntity().getLocation().getWorld(); for(Block b : list){ w.spawnFallingBlock(b.getLocation(), b.getType(), (byte) 0); b.setType(Material.AIR); } } private List<Block> getBlocksToFall(EntityExplodeEvent e){ List<Block> affectedBlocks = e.blockList(); List<Integer> xs = new ArrayList<Integer>(); List<Integer> zs = new ArrayList<Integer>(); int exY = e.getEntity().getLocation().getBlockY(); for(Block affectedBlock : affectedBlocks){ Location loc = affectedBlock.getLocation(); int x = loc.getBlockX(); if(!xs.contains(x)){ xs.add(x); } int z = loc.getBlockZ(); if(!zs.contains(z)){ zs.add(z); } } List<Block> blocksToFall = new ArrayList<>(); for(int y = exY; y <= e.getEntity().getLocation().getWorld().getMaxHeight(); y++){ for(int x : xs){ for(int z : zs){ Location loc = new Location(e.getEntity().getLocation().getWorld(), x, y, z); Block b = e.getEntity().getLocation().getWorld().getBlockAt(loc); if(b.getType() != Material.AIR){ blocksToFall.add(b); } } } } return blocksToFall; }
December 2, 20168 yr That Block class in Bukkit isn't the Block class in Minecraft. That's your biggest mistake, thinking they were the same thing. Minecraft's Block class does not have a getLocation() method (and never did), that must be a Bukkit wrapper. Also, any time you're making a list of something, and then a second list that is 1:1 with it, you need a class. It's called Point and has two public fields: X and Y (or in your case Z, because you care about Minecraft's Z axis) and then you make a list of points. Also, why are your explosions affecting blocks with an airgap? If an explosion happens on the surface (Y=65) why should my floating island house (Y=128, 60 blocks of air away) fall down? 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.
December 2, 20168 yr Author That Block class in Bukkit isn't the Block class in Minecraft. That's your biggest mistake, thinking they were the same thing. Minecraft's Block class does not have a getLocation() method (and never did), that must be a Bukkit wrapper. I know that, I never said that the Code in Bukkit is the same in Minecraft I just said that the getList Method is the same method in Minecraft as in Bukkit (code changed for Minecraft compatibility) Also, why are your explosions affecting blocks with an airgap? If an explosion happens on the surface (Y=65) why should my floating island house (Y=128, 60 blocks of air away) fall down? That's a good question
December 2, 20168 yr That Block class in Bukkit isn't the Block class in Minecraft. That's your biggest mistake, thinking they were the same thing. Minecraft's Block class does not have a getLocation() method (and never did), that must be a Bukkit wrapper. I know that, I never said that the Code in Bukkit is the same in Minecraft I just said that the getList Method is the same method in Minecraft as in Bukkit (code changed for Minecraft compatibility) Sorry I didn't mean to imply that you were saying that. I was pointing it out, as it may have caused confusion. 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.
December 2, 20168 yr Author That Block class in Bukkit isn't the Block class in Minecraft. That's your biggest mistake, thinking they were the same thing. Minecraft's Block class does not have a getLocation() method (and never did), that must be a Bukkit wrapper. I know that, I never said that the Code in Bukkit is the same in Minecraft I just said that the getList Method is the same method in Minecraft as in Bukkit (code changed for Minecraft compatibility) Sorry I didn't mean to imply that you were saying that. I was pointing it out, as it may have caused confusion. Oh sorry, too. I try find the probleme tomorrow with the debugger and than I can say you the result.
December 3, 20168 yr Author Ok I find out that the falling sands spawn for a short time but then they despawn...and I find out that the getBlocksToFall Method doesnt work....
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.