Jump to content

Recommended Posts

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

Posted

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

Posted

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!

Posted

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

Posted

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!

Posted

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]

Posted

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!

Posted

"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!

Posted

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

Posted

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

Posted

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.

Posted

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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