![](https://forums.minecraftforge.net/uploads/set_resources_2/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
clowcadia
-
Posts
458 -
Joined
-
Last visited
Posts posted by clowcadia
-
-
7 minutes ago, Jay Avery said:
An update for anyone who's interested. I've made a searching algorithm that finds all connected trunk blocks, and connected leaves up to a certain count, starting closest to the trunk. I use it in this method, (and use the search results to make all the tree blocks fall). If anyone has ideas on how to improve the performance I'd be grateful - I know I've used several different collections to keep track of all the checking but I couldn't think of any way to reduce that further.
-
How is this?
getIBS(pos).getValue(BlockLeaves.CHECK_DECAY
-
but how does it know its that exact block
-
not sure how to do that, something like this
(BlockLeaves)getBlock(pos).
-
I dotn want to create a new topic for this, as my issues is with he the same theme..
-
cant figure out how get that to work
if(getBlock(pos).isLeaves(getIBS(pos),this.test.world,pos) && (BlockLeaves)getIBS(pos).getValue(CHECK_DECAY)){
CHECK_DECAY is in red
-
i was just about to say\
state.getValue(CHECK_DECAY)
-
lol the beginner modders challenge this is
-
wow seams like we are working on the exact same thing, realisting wood chopper haha
yea that a good idea, one of my next steps is to place the log onthe ground with a tree leaves (i just realized to match the tree leave structure will be difficult, i was just gonna do block like bush, but not realistic enough), and then i am gonna take a look at the leaf connection to a tree
-
oh i just realized once all the log blocks are done u could probably check if the leave block is decaying to make sure it belongs to the tree
-
Hey Jay Every check out my AI task that chops a whole tree down, see what you thing . any criticism
-
actually i think ur right
-
but get block gets the block with the right position
-
Ok now it only removes the selected block, but does not go through any of the loops
passes first check but fails on the loops
-
call me retarded...
-
ok never mind, what about iblock access? whats that
-
-
i cant seem to use Block.isWood() its red, and the get block is going through a loop, it doesnt use on the same value
-
its the i-- that did it
-
-
so i got me a tree chopping loop, then the block position of a tree is selected on the 3 log from the buttom its cuts that log and one down but not the one inside dirt, and then it cuts all blocks from above the 3 log
wondering if anyone knows why
if(getBlock() == Blocks.LOG | getBlock() == Blocks.LOG2){ test.world.setBlockToAir(getPos()); for(int i=1; getBlock(getPos().down(i)) == Blocks.LOG | getBlock(getPos().down(i)) == Blocks.LOG2; i--){ test.world.setBlockToAir(getPos().down(i)); } for(int i=1; getBlock(getPos().up(i)) == Blocks.LOG | getBlock(getPos().up(i)) == Blocks.LOG2; i++){ test.world.setBlockToAir(getPos().up(i)); } }
-
I just dont understand what do they mean by a mutable blockpos... i believe this it to know how block leaves fall ass they devay or get destroyed when the trunk is destroyed i believe
-
I think its in BlockLeaves
the code is hard to understand though
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (!worldIn.isRemote) { if (((Boolean)state.getValue(CHECK_DECAY)).booleanValue() && ((Boolean)state.getValue(DECAYABLE)).booleanValue()) { int i = 4; int j = 5; int k = pos.getX(); int l = pos.getY(); int i1 = pos.getZ(); int j1 = 32; int k1 = 1024; int l1 = 16; if (this.surroundings == null) { this.surroundings = new int[32768]; } if (worldIn.isAreaLoaded(new BlockPos(k - 5, l - 5, i1 - 5), new BlockPos(k + 5, l + 5, i1 + 5))) { BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int i2 = -4; i2 <= 4; ++i2) { for (int j2 = -4; j2 <= 4; ++j2) { for (int k2 = -4; k2 <= 4; ++k2) { IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2)); Block block = iblockstate.getBlock(); if (!block.canSustainLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2))) { if (block.isLeaves(iblockstate, worldIn, blockpos$mutableblockpos.setPos(k + i2, l + j2, i1 + k2))) { this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = -2; } else { this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = -1; } } else { this.surroundings[(i2 + 16) * 1024 + (j2 + 16) * 32 + k2 + 16] = 0; } } } } for (int i3 = 1; i3 <= 4; ++i3) { for (int j3 = -4; j3 <= 4; ++j3) { for (int k3 = -4; k3 <= 4; ++k3) { for (int l3 = -4; l3 <= 4; ++l3) { if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16] == i3 - 1) { if (this.surroundings[(j3 + 16 - 1) * 1024 + (k3 + 16) * 32 + l3 + 16] == -2) { this.surroundings[(j3 + 16 - 1) * 1024 + (k3 + 16) * 32 + l3 + 16] = i3; } if (this.surroundings[(j3 + 16 + 1) * 1024 + (k3 + 16) * 32 + l3 + 16] == -2) { this.surroundings[(j3 + 16 + 1) * 1024 + (k3 + 16) * 32 + l3 + 16] = i3; } if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16 - 1) * 32 + l3 + 16] == -2) { this.surroundings[(j3 + 16) * 1024 + (k3 + 16 - 1) * 32 + l3 + 16] = i3; } if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16 + 1) * 32 + l3 + 16] == -2) { this.surroundings[(j3 + 16) * 1024 + (k3 + 16 + 1) * 32 + l3 + 16] = i3; } if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + (l3 + 16 - 1)] == -2) { this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + (l3 + 16 - 1)] = i3; } if (this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16 + 1] == -2) { this.surroundings[(j3 + 16) * 1024 + (k3 + 16) * 32 + l3 + 16 + 1] = i3; } } } } } } } int l2 = this.surroundings[16912]; if (l2 >= 0) { worldIn.setBlockState(pos, state.withProperty(CHECK_DECAY, Boolean.valueOf(false)), 4); } else { this.destroy(worldIn, pos); } } } }
-
awsomeness
Scanning trees always return CHECK_DECAY = true
in Modder Support
Posted
So i am working on my tree logging ai, I figured out how to scan 14x14x14 area for any logs and leaves and have their pos set in an array. so after scanning and going through leaves(whole tree intact nothing removed) using this every leaf returns true