## Recommended Posts

I've been trying in vane to simplify a code of mine to make a certain block spread. Started with basic vanilla grass code, which allowed me to speed up the spreading to see if I coded right, which worked. But I thought about changing it so it wouldn't spread as randomly, but within a flat 3x3 square. I was able to code a working code for that, but no matter what I seem to try it doesn't seem to spread at all. Codes below:

Vanilla's updateTick method:

``` 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_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2)
{
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
}
else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9)
{
for (int l = 0; l < 4; ++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) == Blocks.dirt && 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, k1, Blocks.grass);
}
}
}
}
}
```

Current modded updateTick method:

``` public void updateTick(World world, int x, int y, int z, Random random)
{
if (!world.isRemote)
{
if (world.getBlockLightValue(x, y + 1, z) < 4 && world.getBlockLightOpacity(x, y + 1, z) > 2)
{
world.setBlock(x, y, z, Blocks.dirt);
}
else if (world.getBlockLightValue(x, y + 1, z) >= 9)
{
for (int l = 0; l < 97; ++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(x + 1, y, z) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
{
world.setBlock(x + 1, y, z, Blocks.glass);
}
if (world.getBlock(x - 1, y, z) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
{
world.setBlock(x - 1, y, z, Blocks.glass);
}

if (world.getBlock(x, y, z + 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
{
world.setBlock(x, y, z + 1, Blocks.glass);
}
if (world.getBlock(x, y, z - 1) == Blocks.grass && world.getBlockLightValue(x, y + 1, z) >= 4 && world.getBlockLightOpacity(z, y + 1, z) <= 2)
{
world.setBlock(x, y, z - 1, Blocks.glass);
}
}
}
}
}```

Member of Aerotech Networks, a Multi-Gaming server.

Also Currently porting the "Rise of the Automatons" minecraft mod

##### Share on other sites

What all have you tried? I imagine you've tried everything, because there's not much there to fiddle around with, but maybe there's a clue in the things you have tried.

##### Share on other sites

That piece of code

`world.getBlockLightOpacity(z, y + 1, z) <= 2`

shouldn't it be

`(x, y + 1, z)`

?

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

• Hi, I am trying to get custom GUIs working, and I would like to have a GUI that works only client-side, which means that you are not supposed to pull items out, but I do want to display items in my GUI and let the player click them. I have a GUI working that has a size of 54 slots and I made a custom texture to remove the player inventory from the GUI texture (see image) Everything kinda works, but is seems like the inventory is in some way still linked to the player's inventory, even though I didn't add any slots linked to the player's inventory. As an example: If is click in the 5th row of my GUI, I get the chest that was in my hot bar slot (see image). It seems like the handling of the clicking of the inventory is handled by the player inventory still. I also get an error if I click in the bottom row because "java.lang.IndexOutOfBoundsException: Index: 49, Size: 45" the player inventory has a size of 45 I guess? I have posted all my relevant code below, if more is needed to solve this issue please tell me, thanks!   Image of weird behaviour: FlipsMenu.java: Opens the menu by changing a "screen to open" variable that gets checked every tick. AHFlipsGui.java: draws the background image and specifies size of the gui. AHFlipsContainer.java: Where we assign the slots.   AHFlipsInventory.java: The actual inventory.
• Remove Create Steam and Rails And only post the mclo.gs link This is correct - for example, Forge alone loads 2 mods
• Looks like an issue/conflict between createbigcannons and Immersive Portals Make a test without one of these mods

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...