Jump to content

clowcadia

Members
  • Posts

    458
  • Joined

  • Last visited

Posts posted by clowcadia

  1. 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.

     

  2. 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

  3. 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));
                        }
                        
                    }

     

    full tree.png

    some tree.png

  4. 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);
                    }
                }
            }
        }

     

×
×
  • Create New...

Important Information

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