A block that spreads over every block but air?

Recommended Posts

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

Share on other sites

Wah? what is this?

Always, always use good and simple to understand names

Share on other sites

ok thats not very usefull but il be honest i did take some of it from the mycelium class so yea the names arnt very easy to understand

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

Share on other sites

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

Share on other sites

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

Share on other sites

no this hasn't worked its still doing the same thing

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

Share on other sites

what? what does it do/not do?

Share on other sites

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

Share on other sites

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

Share on other sites

wait i dont understand what do i need to change to 0?

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

Share on other sites

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?

-TGG[/code]

Share on other sites

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

Share on other sites

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

Share on other sites

I wont have it spreading that fast but i want it to spread quickly for testing thats all

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

Share on other sites

"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

Share on other sites

"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

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

Share on other sites

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

int j1=y;

Share on other sites

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

Share on other sites

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.

Share on other sites

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

Share on other sites

anyone else think they might have a solution?

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

Share on other sites

anyone?

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

Share on other sites

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);
}
}```

Share on other sites

no i want it to spread on top of adjacent blocks not to be abble to grow ontop of itself

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

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.

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

• Posts

• The crash log file was too large to fit into one pastebin so I had to cut it into 2 parts: Crash Log 1, Crash Log 2 I tried creating a new world in the same modpack and it crashed with the exit code -1: https://pastebin.com/EjvB4WGD before even making it to the creation screen. I had the same world creation crash initially when I was making the pack and I solved it by removing some mods. I was thinking maybe some mod got accidentally deleted but I forgot to update the modlist when finalizing what mods I had in so I'm not sure which ones may have been removed.
• figured it out thank you!
• its still saying the error  https://drive.google.com/file/d/1SKWEhgoKBISB4Uo3lqBZEUAymEsBy0-b/view?usp=sharing   is my modpack is it possibly conflicting with another mod?? because i replaced it with the link you sent and it still gave the error
• Replace it with this build: https://www.curseforge.com/minecraft/mc-mods/better-dogs-x-doggy-talents-next/files/4971380
• how do i downgrade it i have it at 1.18.2 which is what my game version is at

• Who's Online (See full list)

×

• Activity

×
• Create New...