cn.nukkit.block.BlockLiquid Java Examples

The following examples show how to use cn.nukkit.block.BlockLiquid. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NukkitRegistryDumper.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
private Map<String, Object> getMaterial(Block b) {
        Map<String, Object> map = new LinkedHashMap<String, Object>();
        Item item = Item.get(b.getId(), b.getDamage());
        map.put("powerSource", b.isPowerSource());
        map.put("lightOpacity", Block.lightFilter[b.getId()]);
        map.put("lightValue", b.getLightLevel());
//        map.put("usingNeighborLight", b.getUseNeighborBrightness(bs));
        map.put("hardness", b.getHardness());
        map.put("resistance", b.getResistance());
//        map.put("ticksRandomly", b.tickRate());
        map.put("tickRate", b.tickRate());
        map.put("fullCube", b.isSolid() && !b.isTransparent());
        map.put("slipperiness", b.getFrictionFactor());
        map.put("renderedAsNormalBlock", !b.isTransparent());
        //map.put("solidFullCube", b.isSolidFullCube());
        map.put("liquid", b instanceof BlockLiquid);
        map.put("solid", b.isSolid());
        map.put("movementBlocker", b.hasEntityCollision());
        //map.put("blocksLight", m.blocksLight());
        map.put("burnable", b.getBurnAbility() > 0);
        map.put("opaque", !b.isTransparent());
        map.put("replacedDuringPlacement", b.canBeReplaced());
        map.put("toolRequired", b.getToolType() != 0);
        map.put("canBeFlowedInto", b.canBeFlowedInto());
//        map.put("fragileWhenPushed", b instanceof BlockFlowable);
//        map.put("unpushable", m.getMobilityFlag() == EnumPushReaction.BLOCK);
//        map.put("adventureModeExempt", b.getField(m, Material.class, "isAdventureModeExempt", "field_85159_M"));
        map.put("mapColor", rgb(b.getColor().getRGB()));
        map.put("ambientOcclusionLightValue", b.isSolid() ? 0.2F : 1.0F);
//        try {
//            map.put("ambientOcclusionLightValue", b.b.getAmbientOcclusionLightValue(bs));
//        } catch (NoSuchMethodError ignored) {
//            map.put("ambientOcclusionLightValue", b.isBlockNormalCube(bs) ? 0.2F : 1.0F);
//        }
        map.put("grassBlocking", false); // idk what this property was originally supposed to be...grass uses a combination of light values to check growth
        return map;
    }
 
Example #2
Source File: FoodChorusFruit.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected boolean onEatenBy(Player player) {
    super.onEatenBy(player);
    // Teleportation
    int minX = player.getFloorX() - 8;
    int minY = player.getFloorY() - 8;
    int minZ = player.getFloorZ() - 8;
    int maxX = minX + 16;
    int maxY = minY + 16;
    int maxZ = minZ + 16;

    Level level = player.getLevel();
    if (level == null) return false;

    NukkitRandom random = new NukkitRandom();
    for (int attempts = 0; attempts < 128; attempts++) {
        int x = random.nextRange(minX, maxX);
        int y = random.nextRange(minY, maxY);
        int z = random.nextRange(minZ, maxZ);

        if (y < 0) continue;

        while (y >= 0 && !level.getBlock(new Vector3(x, y + 1, z)).isSolid()) {
            y--;
        }
        y++; // Back up to non solid

        Block blockUp = level.getBlock(new Vector3(x, y + 1, z));
        Block blockUp2 = level.getBlock(new Vector3(x, y + 2, z));

        if (blockUp.isSolid() || blockUp instanceof BlockLiquid ||
                blockUp2.isSolid() || blockUp2 instanceof BlockLiquid) {
            continue;
        }

        // Sounds are broadcast at both source and destination
        level.addSound(player.asBlockVector3().asVector3(), Sound.MOB_ENDERMEN_PORTAL);
        player.teleport(new Vector3(x + 0.5, y + 1, z + 0.5), PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
        level.addSound(player.asBlockVector3().asVector3(), Sound.MOB_ENDERMEN_PORTAL);

        break;
    }

    return true;
}
 
Example #3
Source File: LiquidFlowEvent.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public LiquidFlowEvent(Block to, BlockLiquid source, int newFlowDecay) {
    super(to);
    this.to = to;
    this.source = source;
    this.newFlowDecay = newFlowDecay;
}
 
Example #4
Source File: LiquidFlowEvent.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public BlockLiquid getSource() {
    return this.source;
}