java - Cannot make a static reference to the non-static method when using World.setBlock() in MC Forge -
first of all, know question has been beaten death, can't seem figure out how use answers in code.
now, i'm trying make minecraft mod set block location of entity using world.setblock()
the issue is, once put of arguments in, eclipse says cannot make static reference non-static method.
i understand supposed make instance of non-static method in class can't seem figure out how make work.
here code:
package noahc3.materialblobs; import net.minecraft.entity.entitylivingbase; import net.minecraft.entity.projectile.entitythrowable; import net.minecraft.init.blocks; import net.minecraft.util.movingobjectposition; import net.minecraft.util.movingobjectposition.movingobjecttype; import net.minecraft.world.world; public class entitydirtblob extends entitythrowable { world world = new world(); //the above line part can't figure out how correctly. public entitydirtblob(world par1world, double par2, double par4, double par6) { super(par1world, par2, par4, par6); } public entitydirtblob(world par1world, entitylivingbase par2entitylivingbase) { super(par1world, par2entitylivingbase); } public entitydirtblob(world par1world) { super(par1world); } @override protected void onimpact(movingobjectposition mop) { if(mop.typeofhit == movingobjecttype.block) { switch(mop.sidehit) { case 0: //bottom mop.blocky--; break; case 1: //top mop.blocky++; break; case 2: //east mop.blockz--; break; case 3: //west mop.blockz++; break; case 4: //north mop.blockx--; break; case 5: //south mop.blockx++; break; } world.setblock(mop.blockx, mop.blocky, mop.blockz, blocks.dirt) //the above line eclipse complains cannot make static reference non-static method } if (!this.worldobj.isremote) { this.setdead(); } system.out.println("entity landed!"); } }
i commented in couldn't figure out how solve issue.
thanks!
you need replace world.setblock
world.setblock
.
the first references world
class , second references instance of world
created.
Comments
Post a Comment