Started by
diniboy
on
Topic category: Help with Minecraft modding (Java Edition)
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!
Try something like:
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayerclass,box);
if(!list.isEmpty()){
Hi Nuparu!
Thanks for UR quick answer! :)
It tried it (pasted this to the custom code section), but it says an error...:
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayerclass,box);
if(!list.isEmpty()){
setLightLevel(1.8F);
}
else{
setLightLevel(0.0F);
}
And here is the gradle log:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posX
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posY
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posZ
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posX
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posY
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(this.posX - 9, this.posY -9, this.posZ -9, this.posX + 9, this.posY + 9, this.posZ + 9);
^
symbol: variable posZ
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:165: error: cannot find symbol
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayerclass,box);
^
symbol: variable EntityPlayerclass
location: class BlockSpecialNightLight
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_specialNightLight.java:165: error: cannot find symbol
List list = this.worldObj.getEntitiesWithinAABB(EntityPlayerclass,box);
^
symbol: variable worldObj
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
8 errors
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Thanks!
Oh , sorry , my mistake. It was for entity , not block. So for block it is:
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(pos.getX() - 9, pos.getY() -9, pos.getZ() -9, pos.getX() + 9, pos.getY() + 9, pos.getZ() + 9);
List list = world.getEntitiesWithinAABB(EntityPlayer.class,box);
if(!list.isEmpty()){
Thank You very much! :) I'll try it tomorrow.
2. I have a second question regarding the flower. I created a texture in GIMP (i'm using linux), but it's similar than a torch (for example). It isn't a simple block, it's just a "thin" block. But I Can't find flower in the TX options at MCreator. So How Can I insert it to the game correctly?
Thanks once again!
@#3 I tried Your code, but it says the following:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\Pisti\Mcreator\forge\build\sources\main\java\mod\mcreator\mcreator_flower.java:164: error: cannot find symbol
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(pos.getX() - 9, pos.getY() -9, pos.getZ() -9, pos.getX() + 9, pos.getY() + 9, pos.getZ() + 9);
^
symbol: method getBoundingBox(int,int,int,int,int,int)
location: class AxisAlignedBB
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
1 error
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Thanks!
@#3.1 Change "AxisAlignedBB.getBoundingBox" to the "new AxisAlignedBB" . The previous method is for 1.7.10
@#3.1.1 Ok. I'm using 1.8.9 forge.
Hi!
I tried created a block which only lights at night and the player radius is minimum 3 blocks from the block with Your code. Now I Can compile it without any errors, but it not works if I try it...
Here You Can read the 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;
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()){
setLightLevel(1.5F);
}
else{
setLightLevel(0.2F);
}
}
if(world.isDaytime()){
setLightLevel(0.0F);
}
world.scheduleUpdate(new BlockPos(i, j, k), this, this.tickRate(world));
}
Thanks!
Nobody?
Try make this variable:
protected static World theWorld;
And use this methods:
public void updateTick(World world, int x, int y, int z, Random par5Random) {
if(theWorld == null)
theWorld = world; //make sure theWorld is not null
getLightValue(null, x, y, z); //force recheck of light level, probably not needed
world.scheduleBlockUpdate(x, y, z, blockID, 600); //schedule another update
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
if(theWorld != 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()){
return 10;
}
else{
return 2;
}
}
if(world.isDaytime()){
return 0;
}
}
else
return 2;
}
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!
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;
Can U help me? :)
@#10 I will look on it today.