change lever

zatalian

New Member
Hi,

I'm trying to change the position of a lever from within my plugin. What object/function do i need for that?
This is what i have:

Block block = Main.getInstance().getServer().getLevelByName(level).getBlock(((Long) position.get(0)).intValue(), ((Long) position.get(1)).intValue(), ((Long) position.get(2)).intValue());

Main.getInstance().getLogger().info("position x: " + block.getX());
Main.getInstance().getLogger().info("position y: " + block.getY());
Main.getInstance().getLogger().info("position z: " + block.getZ());

BlockLever lever = (BlockLever) block;
Main.getInstance().getLogger().info("lever is on? " + lever.isPowerOn());
Main.getInstance().getLogger().info("lever is power source? " + lever.isPowerSource());


... is there something like lever.setPower()?
 

CreeperFace

🇨🇿🇺🇦 Слава Україні!
Staff member
Hi,

I'm trying to change the position of a lever from within my plugin. What object/function do i need for that?
This is what i have:

Block block = Main.getInstance().getServer().getLevelByName(level).getBlock(((Long) position.get(0)).intValue(), ((Long) position.get(1)).intValue(), ((Long) position.get(2)).intValue());

Main.getInstance().getLogger().info("position x: " + block.getX());
Main.getInstance().getLogger().info("position y: " + block.getY());
Main.getInstance().getLogger().info("position z: " + block.getZ());

BlockLever lever = (BlockLever) block;
Main.getInstance().getLogger().info("lever is on? " + lever.isPowerOn());
Main.getInstance().getLogger().info("lever is power source? " + lever.isPowerSource());


... is there something like lever.setPower()?
that will switch level state
https://github.com/NukkitX/Nukkit/blob/master/src/main/java/cn/nukkit/block/BlockLever.java#L67
Then you must set the block again
 
Top