本文整理汇总了Java中cn.nukkit.redstone.Redstone类的典型用法代码示例。如果您正苦于以下问题:Java Redstone类的具体用法?Java Redstone怎么用?Java Redstone使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Redstone类属于cn.nukkit.redstone包,在下文中一共展示了Redstone类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAroundRedstone
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public void updateAroundRedstone(Block block) {
BlockUpdateEvent ev = new BlockUpdateEvent(block);
this.server.getPluginManager().callEvent(ev);
if (!ev.isCancelled()) {
for (Entity entity : this.getNearbyEntities(
new AxisAlignedBB(block.x - 1, block.y - 1, block.z - 1, block.x + 1, block.y + 1, block.z + 1))) {
entity.scheduleUpdate();
}
ev.getBlock().onUpdate(BLOCK_UPDATE_NORMAL);
RedstoneUpdateEvent rsEv = new RedstoneUpdateEvent(ev.getBlock());
this.server.getPluginManager().callEvent(rsEv);
if (!rsEv.isCancelled()) {
Block redstoneWire = rsEv.getBlock().getSide(Vector3.SIDE_DOWN);
if (redstoneWire instanceof BlockRedstoneWire) {
if (rsEv.getBlock() instanceof BlockSolid) {
int level = redstoneWire.getPowerLevel();
redstoneWire.setPowerLevel(redstoneWire.getNeighborPowerLevel() - 1);
redstoneWire.getLevel().setBlock(redstoneWire, redstoneWire, true, true);
Redstone.deactive(redstoneWire, level);
} else {
redstoneWire.setPowerLevel(redstoneWire.getNeighborPowerLevel() - 1);
redstoneWire.getLevel().setBlock(redstoneWire, redstoneWire, true, true);
Redstone.active(redstoneWire);
}
}
}
}
}
示例2: onUpdate
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
if ((type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_SCHEDULED) && this.getNeighborPowerLevel() > 0) {
int level = this.getPowerLevel();
Redstone.deactive(this, level);
this.getLevel().setBlock(this, new BlockLitRedstoneLamp());
}
return 0;
}
示例3: place
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, int face, double fx, double fy, double fz, Player player) {
if (this.getSide(Vector3.SIDE_DOWN).isTransparent()) {
return false;
} else {
this.setPowerLevel(this.getNeighborPowerLevel() - 1);
block.getLevel().setBlock(block, this, true, true);
Redstone.active(this);
return true;
}
}
示例4: onBreak
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean onBreak(Item item) {
int level = this.getPowerLevel();
this.getLevel().setBlock(this, new BlockAir(), true, false);
Redstone.deactive(this, level);
return true;
}
示例5: place
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, int face, double fx, double fy, double fz, Player player) {
Block below = this.getSide(0);
if (!target.isTransparent() && face != 0) {
int[] faces = new int[]{
0, //0, nerver used
5, //1
4, //2
3, //3
2, //4
1, //5
};
this.meta = faces[face];
this.getLevel().setBlock(block, this, true, true);
Redstone.active(this);
return true;
} else if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL) {
this.meta = 0;
this.getLevel().setBlock(block, this, true, true);
Redstone.active(this);
return true;
}
return false;
}
示例6: onBreak
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean onBreak(Item item) {
int level = this.getPowerLevel();
this.getLevel().setBlock(this, new BlockAir(), true, true);
Redstone.deactive(this, level);
return true;
}
示例7: place
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean place(Item item, Block block, Block target, int face, double fx, double fy, double fz, Player player) {
this.getLevel().setBlock(block, this, true, false);
Redstone.active(this);
this.getLevel().updateAllLight(this);
this.getLevel().updateAroundRedstone(this);
this.getLevel().updateAround(block);
return true;
}
示例8: onActivate
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
this.meta ^= 0x08;
this.getLevel().setBlock(this, this, true, true);
this.getLevel().addSound(new LeverSound(this, this.isPowerOn()));
if (this.isPowerOn()) {
this.setPowerSource(true);
Redstone.active(this);
} else {
this.setPowerSource(false);
Redstone.deactive(this, this.getPowerLevel());
}
return true;
}
示例9: onUpdate
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
if ((type == Level.BLOCK_UPDATE_NORMAL || type == Level.BLOCK_UPDATE_SCHEDULED) && this.getNeighborPowerLevel() > 0) {
int level = this.getPowerLevel();
Redstone.deactive(this, level);
this.getLevel().setBlock(this, new BlockRedstoneLampLit());
}
return 0;
}
示例10: BlockRedstoneTorch
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockRedstoneTorch(int meta) {
super(meta);
this.setPowerSource(true);
this.setPowerLevel(Redstone.POWER_STRONGEST);
}
示例11: BlockRedstone
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockRedstone(int meta) {
super(0);
this.setPowerSource(true);
this.setPowerLevel(Redstone.POWER_STRONGEST);
}
示例12: BlockLever
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockLever(int meta) {
super(meta);
this.setPowerLevel(Redstone.POWER_STRONGEST);
}
示例13: onBreak
import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
@Override
public boolean onBreak(Item item) {
this.getLevel().setBlock(this, new BlockAir(), true, true);
Redstone.deactive(this, this.getPowerLevel());
return true;
}