当前位置: 首页>>代码示例>>Java>>正文


Java Redstone类代码示例

本文整理汇总了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);
                }
            }
        }
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:30,代码来源:Level.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:10,代码来源:BlockRedstoneLamp.java

示例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;
    }
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:12,代码来源:BlockRedstoneWire.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:8,代码来源:BlockRedstoneWire.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:28,代码来源:BlockRedstoneTorch.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:8,代码来源:BlockRedstoneTorch.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:10,代码来源:BlockRedstone.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:16,代码来源:BlockLever.java

示例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;
}
 
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:10,代码来源:BlockRedstoneLamp.java

示例10: BlockRedstoneTorch

import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockRedstoneTorch(int meta) {
    super(meta);
    this.setPowerSource(true);
    this.setPowerLevel(Redstone.POWER_STRONGEST);
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:6,代码来源:BlockRedstoneTorch.java

示例11: BlockRedstone

import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockRedstone(int meta) {
    super(0);
    this.setPowerSource(true);
    this.setPowerLevel(Redstone.POWER_STRONGEST);
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:6,代码来源:BlockRedstone.java

示例12: BlockLever

import cn.nukkit.redstone.Redstone; //导入依赖的package包/类
public BlockLever(int meta) {
    super(meta);
    this.setPowerLevel(Redstone.POWER_STRONGEST);
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:5,代码来源:BlockLever.java

示例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;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:7,代码来源:BlockLever.java


注:本文中的cn.nukkit.redstone.Redstone类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。