Jump to content

X Squishling X

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by X Squishling X

  1. private static BlockState updateDistance(BlockState blockState, IWorld world, BlockPos blockPos) { int i = distance; try (BlockPos.PooledMutableBlockPos pos = PooledMutableBlockPos.retain().setPos(blockPos)) { loop: for (int k = -1; k < 2; k++) { for (int l = -1; l < 2; l++) { for (int m = -1; m < 2; m++) { if (k == 0 && l == 0 && m == 0) continue; pos.setPos(blockPos.getX() + k, blockPos.getY() + l, blockPos.getZ() + m); i = Math.min(i, getDistance(world.getBlockState(pos)) + 1); if (i <= 1) break loop; } } } } return blockState.with(DISTANCE, Integer.valueOf(i)); } distance is 7, I just did this so I can easily control it.
  2. ah yes, I must've been tired haha other than that, its the same as before
  3. After testing, this updated code still seems to only work horizontally. Does anyone know what's wrong with it? I also updated to this line: if (Math.min(i, getDistance(world.getBlockState(pos)) + 1) < i) i = Math.min(i, getDistance(world.getBlockState(pos)) + 1); Which should take the lowest distance, to see if this could fix something. What else can I try? Multiple people have told me they really want me to keep my current leaves design.
  4. I belive I have fixed it, this is for everyone else that finds this thread: This is the update distance method I have created. I loop through every block in a 3x3 cube around the block, ignoring (0, 0, 0) because that is the block itself (continue will just skip to the next cycle of the loop). I now add these offsets (-1 to 1) to the position to get the blocks around the leaves block. I then set i to the min (it takes the lower) of the distance of this block plus one (because this leaves block is one block over). i is 7 usually, so this means a max range for checking of 7, but you can change that although that also means you will have to change the 7 in multiple places in the code. The get distance method handles what block this is and getting the distance property. If the distance is 1 (or less) we exit. This is because it means we are right next to a log, and otherwise we will keep on searching in case we find another, shorter distance. Finally, we return a block state with the distance property set to the value of i, aka our distance. private static BlockState updateDistance(BlockState p_208493_0_, IWorld p_208493_1_, BlockPos p_208493_2_) { int i = 7; try (BlockPos.PooledMutableBlockPos pos = PooledMutableBlockPos.retain().setPos(p_208493_2_)) { loop: for (int k = -1; k < 2; k++) { for (int l = -1; l < 2; l++) { for (int m = -1; m < 2; m++) { if (k == 0 && l == 0 && m == 0) continue; pos.setPos(p_208493_2_.getX() + k, p_208493_2_.getY() + l, p_208493_2_.getZ() + m); i = Math.min(i, getDistance(p_208493_1_.getBlockState(pos)) + 1); if (i <= 1) break loop; } } } } return p_208493_0_.with(DISTANCE, Integer.valueOf(i)); } For our leaves to work properly, we will also need to update the distance method to ensure it works with our leaves class: private static int getDistance(BlockState neighbor) { if (BlockTags.LOGS.contains(neighbor.getBlock())) { return 0; } else { return (neighbor.getBlock() instanceof LeavesBlock || neighbor.getBlock() instanceof CustomLeaves) ? neighbor.get(DISTANCE) : 7; } } All other methods in the leaves class are copied from LeavesBlock, so you will have to copy the contents of that. Warning: Because we can't edit the normal leaves block class without a core mod, normal leaves won't be able to see that our leaves exist, and so therefore will only work if a normal leaves block is connected to the log. This is usually not an issue, because almost always only one type of leaves is connected to a log.
  5. This document describes to break in a similar way to how I did it: https://www.java67.com/2014/12/how-to-break-from-nested-loop-in-java.html
  6. I know what a mutable block position is, but I've had issues with them in the past so I decided to do this. The reason I am asking for help on this is because I want to know the correct way to do it. I get what you are saying on the other things, but some of it was left over from vanilla where I just tried to edit it, such as the '+ 1' check. Am I looking at the right method? The vanilla code is hard to read sometimes with the lack of comments, and the weird names I assume come from decompiling the code. This is also my first time working with 1.14, although I am sure the leaves aren't very different in 1.12. Oh, and it doesn't work if I move the label below because I get an error that at the time of the break 'loop' wasn't defined.
  7. How would I go about making it work diagonally then? What method would be best to look at?
  8. Huh, I thought it just required that the logs were within a certain distance, and that by default that distance was only calculated straight
  9. I have a palm tree where some leaves stick out diagonally. I'm wondering what the best way to make the leaves support this is? I have tried to override the updateDistance method like so: private static BlockState updateDistance(BlockState p_208493_0_, IWorld p_208493_1_, BlockPos p_208493_2_) { int i = 7; try (BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain()) { loop: for (int k = -1; k < 2; k++) { for (int l = -1; l < 2; l++) { for (int m = -1; m < 2; m++) { if (k == 0 && l == 0 && m == 0) break loop; BlockPos pos = new BlockPos(blockpos$pooledmutableblockpos.getX() + k, blockpos$pooledmutableblockpos.getY() + l, blockpos$pooledmutableblockpos.getZ() + m); i = Math.min(i, getDistance(p_208493_1_.getBlockState(pos)) + 1); if (i == 1) break loop; } } } } return p_208493_0_.with(DISTANCE, Integer.valueOf(i)); } But this just makes my leaves decay even next to the log (it is a vanilla spruce log so the log shouldn't matter). How could I make it support my palm tree? The 'fronds' are about 4-5 blocks long, for reference and some are diagonal.
  10. I have a dimension which uses similar generation to the nether. I have made a biome to go in the dimension, along with a custom tree that I give to the biome using getRandomTreeFeature. Even if I set the top block of the biome to grass (I have made a custom system to handle this), the trees do not generate. Looking at the logs, it seems like every time it tries to generate a tree, it either picks bedrock, air, or stone (the main block of the dimension), and always within 20 blocks vertically of the top roof bedrock, however if I use a vanilla biome it spawns their trees just fine. Does anyone know how to change the trees to spawn on the different layers of my dimension?
  11. Place the replaceTopBlocks method in decorate.
  12. You'd probably want to replace the air check with something else, because it means it wont replace the block under tallgrass and such.
  13. private void replaceTopBlocks(int chunkX, int chunkZ) { int x = (chunkX * 16) + 8; int z = (chunkZ * 16) + 8; for (int a = x; a < x + 16; a++) { for (int b = 0; b < world.getHeight(); b++) { for (int c = z; c < z + 16; c++) { replaceTopBlock(a, b, c); } } } } private void replaceTopBlock(int x, int y, int z) { BlockPos position = new BlockPos(x, y, z); if (topBlockReplacements.containsKey(world.getBlockState(position)) && world.getBlockState(position.up()).getBlock() == Blocks.AIR) { world.setBlockState(position, topBlockReplacements.get(world.getBlockState(position))); } } This is the code I am using, topBlockReplacments is a HashMap of two IBlockStates; the first being the original block, second being the block to replace it with.
  14. I would like to have a nether-like dimension with dirt, which on top turns to grass. Obviously I can't use the vanilla `topBlock`, because the nether has multiple layers atop eachother. What method would I write this in? I have tried just looping through all the blocks in the chunk, and checking if the above block is air, but this is painfully inefficient and causes cascading world generation. Is there a better way to do this? It doesnt appear to work in `populate` either.
  15. I'm adding some guns to my general war mod, and currently I am using a modified version of getMouseOver . My problem comes when the ray-tracing method reaches tall grass, where it acts as if its hit a solid block. I would like to know how I can make it ignore blocks without collision so that it doesn't annoy people trying to shoot a target. Thanks for the help in advance!
  16. If you rename the jar file to name.zip then you can unpack it into a folder.
  17. Do you mean the jar file? It's quite easy to unpack it to get the textures, and you can use a java decompiler to get the code back, although it may not be exactly how it was originally written.
  18. If anyone needs the answer, this is what I did: for (IRecipe recipe : CraftingManager.REGISTRY) { if (recipe.getIngredients().size() == 1) { if (recipe.getIngredients().get(0).test(item)) {
  19. Basically what I want is to get the associated planks block for a log, and how I plan on doing this is getting the shapeless crafting recipe output of a list containing the log. Looking into it there seems to be some stuff about a craftMatrix, I'm not quite sure how to acheive what I want to acheive though. Thanks in advance your your help!
  20. Bump, after some research I have found where the mushroom island is added, but am unsure on how to add a new gen layer to the world generation. Is there some method that will allow me to do this?
  21. I'm looking into creating an island biome in 1.12.2. I could not find code for the Mushroom Island it its biome class, however I have found some island code in GenLayer, which I'm unsure how to use to create my own biome. I have tried to look at other mods, but they have so many layers of their own framework to be able to figure out how to do it. I have concluded from this search however that beach biomes seem to be very prominent in a lot of their code (not sure if theres a correlation or they just like nice beaches). How can I use the island gen layer to create my own island biome? After I figure that out I'm sure it won't be very difficult to make an island interface that can be used, but until then, what do i have to do to create an island? Thanks in advance for your help! ?
  22. Probably would have helped if I had done a registry name, I guess the tutorial I watched for biome had something wrong... Thanks for your help, I've been trying to do this for a while now!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.