Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hi everyone i have made a block that can spread over the top of grass next to it and i tried to do this with all blocks by using block not Blocks.grass but of course this uses air so it spreads in the air i only want it to spread over the surface is there anyway i can make it spread over every block but air?

 

update tick

 

public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)

            {

                if (!p_149674_1_.isRemote)

               

                if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9)

                    {

                        for (int l = 0; l < 45000; ++l)

                        {

                            int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1;

                            int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3;

                            int k1 = p_149674_4_ + p_149674_5_.nextInt(3) - 1;

                            Block block = p_149674_1_.getBlock(i1, j1 + 1, k1);

 

                            if (p_149674_1_.getBlock(i1, j1, k1) == block && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)

                           

                                p_149674_1_.setBlock(i1, j1 + 1, k1, this);

                            }

                           

                           

                        }

                    }

BioWarfare Mod: http://goo.gl/BYWQty

  • Author

better?

 

 

public void updateTick(World world, int x, int y, int z, Random random)

            {

                if (!world.isRemote)

               

                if (world.getBlockLightValue(x, y + 1, z) >= 9)

                    {

                        for (int l = 0; l < 45000; ++l)

                        {

                            int i1 = x + random.nextInt(3) - 1;

                            int j1 = y + random.nextInt(5) - 3;

                            int k1 = z + random.nextInt(3) - 1;

                            Block block = world.getBlock(i1, j1 + 1, k1);

 

                            if (world.getBlock(i1, j1, k1) == block && world.getBlockMetadata(i1, j1, k1) == 0 && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)

                           

                                world.setBlock(i1, j1 + 1, k1, this);

                            }

                           

                           

                        }

                    }

             

BioWarfare Mod: http://goo.gl/BYWQty

yeah, way better.

 

public void updateTick(World world, int x, int y, int z, Random random)
            {
                if (!world.isRemote)
                   

                        for (int i = 0; l < 45000; ++l)
                        {
                            int i1 = x + random.nextInt(3) - 1;
                            int j1 = y + random.nextInt(3) - 1;
                            int k1 = z + random.nextInt(3) - 1;
                            Block block = world.getBlock(i1, j1 + 1, k1);

                            if (world.getBlock(i1, j1, k1) != Blocks.air){
                           
                                world.setBlock(i1, j1 + 1, k1, this);
                            }
                           
                           
                        
                    }

try something like thisthis

Here could be your advertisement!

  • Author

ive done this and its fixed the problem but now it is spreading down :(

 

  if (world.getBlock(i1, j1, k1) ==block &&  (world.getBlock(i1, j1, k1) != Blocks.air)){

                               

                                world.setBlock(i1, j1 + 1, k1, this);

                            }

BioWarfare Mod: http://goo.gl/BYWQty

yeah, i know.

 

                            int i1 = x + random.nextInt(3) - 1;
                            int j1 = y + random.nextInt(3) - 1;
                            int k1 = z + random.nextInt(3) - 1;
                            Block block = world.getBlock(i1, j1 + 1, k1);

                            if (world.getBlock(i1, j1, k1) != Blocks.air){
                           
                                world.setBlock(i1, j1 + 1, k1, this);
                            }

 

j1 is the y coordinate (height) from the block it spreads to, right?. it basically is the blocks current location plus a random number.

ok, what is this random number?

int j1 = y + random.nextInt(3) - 1;

it is either:

0

1 or

2

minus 1. his means that it can spread

-1(down)

0(same y)

+1(up)

 

 

 

sry accidentaly had a 2 there, my fault, fixed it secs before your post

Here could be your advertisement!

By crikey dude, where did that 45000 come from?  You will be running that setBlock loop 45000 times for every block you add.

 

                        for (int l = 0; l < 45000; ++l)
                        {

 

 

Another question  - what's the point of having a random value for y?

 

And in fact, why are you using random values for x and z as well?  Why not just try the four adjacent blocks?

 

This link might help you a bit, perhaps?

http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html

-TGG[/code]

guess he wants that his block spreads as fast as possible:D

 

if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2

Here could be your advertisement!

by Crikey dude

 

I might have to add that to my signature. +3 reddit gold!

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

"if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2"

 

No i want it so that it dosen't spread upwards

BioWarfare Mod: http://goo.gl/BYWQty

"if you want that your block spreads only upwards you have to remove the -1 from the new y(j1) coordinate and change the 3 to a 2"

 

No i want it so that it dosen't spread upwards

it shouldn't spread up/down?

than you can us your block y coordinate 1:1 for your new blocks y(=j1) coordinate.

Here could be your advertisement!

  • Author

i dont know if i have done the right thing but this dosen't work.

 

public void updateTick(World world, int x, int y, int z, Random random)

            {

                if (!world.isRemote)

               

                if (world.getBlockLightValue(x, y + 1, z) >= 9)

                    {

                        for (int l = 0; l < 45000; ++l)

                        {

                        int i1 = x + random.nextInt(3) - 1;

                            int j1 = y + random.nextInt(3) - 1;

                            int k1 = z + random.nextInt(3) - 1;

                            Block block = world.getBlock(i1, j1 + 1, k1);

 

                            if (world.getBlock(i1, j1, k1) != Blocks.air){

                         

                                world.setBlock(x, j1 + 1, z, this);

                            }

                        }

                        }

                    }

BioWarfare Mod: http://goo.gl/BYWQty

  • Author

now this is just spreading up :(

 

public void updateTick(World world, int x, int y, int z, Random random)

            {

                if (!world.isRemote)

               

                if (world.getBlockLightValue(x, y + 1, z) >= 9)

                    {

                        for (int l = 0; l < 45000; ++l)

                        {

                        int i1 = x + random.nextInt(3) - 1;

                        int j1=y;

                            int k1 = z + random.nextInt(3) - 1;

                            Block block = world.getBlock(i1, j1 + 1, k1);

 

                            if (world.getBlock(i1, j1, k1) != Blocks.air){

                         

                                world.setBlock(i1, j1 + 1, k1, this);

                            }

                        }

                        }

                    }

             

 

BioWarfare Mod: http://goo.gl/BYWQty

Please use [ code ] tags.

 

It's just spreading up because you're setting the block above with your

j1 + 1

. Change that to just

j1

.

 

In fact, remove

j1

altogether and just use

y

.

 

Also, as has been pointed out, running 45000 iterations is a bit overkill.

  • Author

I dont think you understand i want it to spread over the top of blocks next to it if i remove the +1 it will just delete that block and replace it with itself

BioWarfare Mod: http://goo.gl/BYWQty

I dunno, it works

 

    public void updateTick(World world, int x, int y, int z, Random random)
    {
            if (!world.isRemote && world.getBlockLightValue(x, y + 1, z) >= 9)
                for (int i = 0; i < 4; ++i)
                {
                    int randX = x + random.nextInt(3) - 1;
                    int randY = y + random.nextInt(3) - 1;
                    int randZ = z + random.nextInt(3) - 1;

                    if (world.getBlock(randX, randY, randZ) != Blocks.air)
                        world.setBlock(randX, randY, randZ, Yormod.yourblock);
                }
    }

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.