How Can I check "is player below a radius from the block"?

Started by diniboy on

Topic category: Help with modding (Java Edition)

Last seen on 17:10, 11. Sep 2016
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How Can I check "is player below a radius from the block"?

Hi!

I tried to create some flowers with mcreator. I created a flower which can "eat" the player, but I Can't find any action to check the nearest player distance smaller than nine or something...

Is there a way to check this?

Thanks!

Last seen on 22:13, 3. Apr 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
So best results i got with
Sun, 04/17/2016 - 09:15

So best results i got with this code. But you should propably change the tickrate to bigger.
 

static{

block = (BlockTestBlockish)(new BlockTestBlockish().setHardness(2.0F)
.setResistance(10.0F)
.setUnlocalizedName("TestBlockish")
.setLightOpacity(0)
.setStepSound(Block.soundTypeStone)
.setCreativeTab(CreativeTabs.tabBlock)
);block.setBlockBounds(0.0F,0.0F,0.0F,1.0F,1.0F,1.0F);
block.setHarvestLevel("pickaxe", 0);
}

public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
static class BlockTestBlockish extends Block
{

int a1 = 0,a2 = 0,a3 = 0,a4 = 0,a5 = 0,a6 = 0;

boolean red = false;

private World worldion = null;
private BlockPos position = null;

 

protected BlockTestBlockish()
{
        super(Material.ground);

GameRegistry.registerBlock(this, "TestBlockish");

}


public void onBlockAdded(World world, BlockPos pos, IBlockState state){
int i = pos.getX();int j = pos.getY();int k = pos.getZ();world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));

}


@Override
public int tickRate(World world)
{
    return 40;
}

public void updateTick(World world, BlockPos pos, IBlockState state, Random random){
 this.worldion = world;
 this.position = pos;
 if(!world.isRemote){
getLightValue();}
world.scheduleUpdate(pos, this, this.tickRate(world));
}

@Override
public int getLightValue() {
    int value = 0;
World world = this.worldion;
BlockPos pos = this.position;
if(world != null) {

if(!world.isDaytime()){
AxisAlignedBB box = new AxisAlignedBB(pos.getX() - 3, pos.getY() -3, pos.getZ() -3, pos.getX() + 3, pos.getY() + 3, pos.getZ() + 3);
     
     
        List list = world.getEntitiesWithinAABB(EntityPlayer.class,box);
         if(!list.isEmpty()){
             
             value = 15;
         }
         else{
            value = 8;
         }
}

if(world.isDaytime()){
value = 0;
}

}

else{
value = 8;
}

        return value;
}
}

Last seen on 17:10, 11. Sep 2016
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hi!
Mon, 04/18/2016 - 16:10

Hi!

 

I tried it, but it says something like this:

 

\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_testBlockish.java:294: error: reached end of file while parsing
}

Last seen on 17:10, 11. Sep 2016
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:So best results i got with
Mon, 04/18/2016 - 16:20

@#11 Ohh, sorry that was my mistake... I missed the closing } of public class mcreator_TestBlockish { ...

Last seen on 17:10, 11. Sep 2016
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks. I tried it. It works
Mon, 04/18/2016 - 17:09

Thanks. I tried it. It works if I place it and a Player go in 3 block radius. But if the player exit from the area the flower not change the lightlevel...

What's wrong?

Last seen on 17:10, 11. Sep 2016
Joined Mar 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Thanks. I tried it. It works
Sun, 09/11/2016 - 16:25

Hi!

I wanted to try it, with the latest, 1.7.0 MCreator. But it says a symbol error:

C:\Pylo\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_nightFlower.java:115: error: cannot find symbol
               this.worldion = world;

                   ^

 

So, what Can I do?

 

Many thanks!

Last seen on 22:13, 3. Apr 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Do you have defined the
Sun, 09/11/2016 - 17:21

Do you have defined the varible worldion of type World?

Last seen on 12:45, 29. Jun 2019
Joined Dec 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
  Hey, I'm trying to create…
Thu, 06/28/2018 - 15:18

 

Hey, I'm trying to create a creature that explodes, if there are 3 blocks from the player, can you help me?