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

Started by diniboy on Mon, 04/11/2016 - 18:17

Topic category: Help with MCreator modding

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

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
How Can I check "is player below a radius from the block"?
Mon, 04/11/2016 - 18:17

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 17:10, 11. Sep 2016
Joined Mar 2016
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Here is the gradle log after
Fri, 04/15/2016 - 14:22

Here is the gradle log after I paste the code:

 

http://pastebin.com/raw/6pX76szy

 

Ps: I think this code don't change the LightLevel, it controlls only the variable isn't it?

 

Thanks!

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

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
And here is my 1.8.9 mcreator
Fri, 04/15/2016 - 14:33

And here is my 1.8.9 mcreator's update tick code:

 

public void updateTick(World world, BlockPos pos, IBlockState state, Random random){
int i = pos.getX();int j = pos.getY();int k = pos.getZ();EntityPlayer entity = Minecraft.getMinecraft().thePlayer;

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

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Can U help me? :)
Sat, 04/16/2016 - 19:00

Can U help me? :)

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
RE:Can U help me? :)
Sat, 04/16/2016 - 19:34

@#10 I will look on it today.

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
  • wiki contributor
  • moderator
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
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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 00:21, 11. Aug 2019
Joined Aug 2013
User points:

Statistics:

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

Do you have defined the varible worldion of type World?