# How to make a check other blocks in a radius help?

## Recommended Posts

Hey,

I'm making this block called the Terra Stone and I've gotten it to speed up the growth of plants around it, but it only works with blocks right next to it, how can I make the radius it works in larger? Here's my code:

```package net.minecraft.src;

import java.util.Random;

public class TileEntityTerraStone extends TileEntity
{
public Block terraBlock;

Random rand = new Random();

public void updateAdjacentCrop(World world, int x, int y, int z)
{

int blockId = world.getBlockId(x, y, z);
if (Block.blocksList[world.getBlockId(x, y, z)] instanceof BlockCrops)
{
if(rand.nextInt(1) == 0);
}
}

public void updateAdjacentSapling(World world, int x, int y, int z)
{
int blockId = world.getBlockId(x, y, z);
if (Block.blocksList[world.getBlockId(x, y, z)] instanceof BlockSapling)
{
if(rand.nextInt(1) == 0);
}
}
}```

##### Share on other sites

Well you need to figure out a way to interact with the blocks around your block...

So how would you get to know what kind of block is located 2 blocks to the north of the Terra Stone itself?

If you guys dont get it.. then well ya.. try harder...

##### Share on other sites

Not sure if you have seen this yet, but if you can answer to what you know and how you think about the problem I'd be happy to try to help

If you guys dont get it.. then well ya.. try harder...

##### Share on other sites

just create a searching method that start at xyz and miniz 4 from the xz coord. then work you way too xz plus 4 using a few "for"statements with an "if" statement in the middle.

something like this

```public Block findBlock(int x,int y,int x, int blockid,int radius)
{
y-=1;
for(int k =0; k < 2; k++)
{
for(int j =0; j < radius; j++)
{
for(int i =0; i < radius; i++)
{
Block block = worldObj.getblock(xyz);
if(block.blockID == blockID)
{
return block;
z++;
}
x++;
}
y++;
}
}
```

##### Share on other sites

Just one small issue with that one: It will only find the first one, because it stops at the "return" statement.

##### Share on other sites

Just one small issue with that one: It will only find the first one, because it stops at the "return" statement.

I think that was the whole point of that piece of code, but you can just simply change the return statement to do what ever you want it to do. You could return a whole List/Array of the blocks or just an Integer (

`int`

), which returns the amount of the blocks it can find with the same Block ID. There is so much you can do with that little function

##### Share on other sites

Just one small issue with that one: It will only find the first one, because it stops at the "return" statement.

I think that was the whole point of that piece of code, but you can just simply change the return statement to do what ever you want it to do. You could return a whole List/Array of the blocks or just an Integer (

`int`

), which returns the amount of the blocks it can find with the same Block ID. There is so much you can do with that little function

yep thought i give an example and let everyone else work out what they want it too do. I use a similar version of this for harvesting wood that why it returns the first instance. It follows the same idea of Buildcraft quarry going from one top corner to another bottom corner. I have another version that will find every last instance of a block then mark it for harvesting.

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

• Hey everyone, I am starting a brand new Minecraft server by the name “WILZON”. This server will include game modes such as Skyblock, PVP, Survival, but it is mainly focused and based on the Survival gamemode. As of right now, the staff that will be recruited won’t be paid so this will only be volunteer work at the moment… BUT in the future when the server starts making money, the staff WILL be paid by splitting the revenue! What am I looking for?: Plugin Manager(s) Someone/People with Server knowledge Someone/People with Server experiences Someone/People who could moderate the server Builder(s) Someone who would be willing to promote/advertise (if possible) Tester(s) If you have anymore questions or are interested, DM me on Discord @wilzonn OR you can join this Server (https://discord.gg/eDwhHwygzW)
• Damn it was good mod, sad i had to remove it, but it worked and thank you so much for your help! Also, 2 things: do you detect what mod is causing the crash by seeing which mod in the crash report is listed the most? And, this is a random question but, do worldgen mods like tectonic cause less mobs to spawn in vanilla and modded biomes? Again thanks so much for your help.
• public class FireDot extends MobEffect { public FireDot() { super(MobEffectCategory.HARMFUL, 0x660990); getLogger().info("Test Log 999994 "); } @Override public void applyEffectTick(LivingEntity entity, int amplifier) { if (entity instanceof LivingEntity) { entity.hurt(entity.damageSources().inFire(), 0.1F + amplifier); getLogger().info("Test Log 22333 : ") } } public boolean isDurationEffectTick(int duration, int amplifier) { int tickInterval = 2; return duration % tickInterval == 0; } } this is my custom MobEffect public class ModEffects { public static final DeferredRegister<MobEffect> MOB_EFFECTS = DeferredRegister.create(ForgeRegistries.MOB_EFFECTS, DoJiJoJu.MODID); public static final RegistryObject<MobEffect> FIRE_DOT = MOB_EFFECTS.register("fire_dot", FireDot::new); public static void register(IEventBus eventBus) {MOB_EFFECTS.register(eventBus);} } and I registed in Registry ModEffects.register(modEventBus); in my Main Class ((LivingEntity) this.target).addEffect(new MobEffectInstance(ModEffects.FIRE_DOT.get(), 100, 1)); getLogger().info("Test Log 888884 " + ModEffects.FIRE_DOT.get()); I add the Effect by this way and the `Log 888884` was printed but other Logs wasn't printed. The effect of MobEffectCategory.HARMFUL, 0x660990 was visible. but the hurt code wasn't work why It doesn't work? I tested in Creative mode and solo play Thank you
• could someone please explain to me why my game keeps crashing whenever I try to load a modpack Here's the crash report https://pastebin.com/HKhwHzN9

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

×

• #### Activity

×
• Create New...