Search in sources :

Example 6 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class ItemFrameDropItemPacket method decode.

@Override
public void decode() {
    BlockVector3 v = this.getBlockVector3();
    this.z = v.z;
    this.y = v.y;
    this.x = v.x;
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 7 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class CommandBlockUpdatePacket method decode.

@Override
public void decode() {
    this.isBlock = this.getBoolean();
    if (this.isBlock) {
        BlockVector3 v = this.getBlockVector3();
        this.x = v.x;
        this.y = v.y;
        this.z = v.z;
        this.commandBlockMode = (int) this.getUnsignedVarInt();
        this.isRedstoneMode = this.getBoolean();
        this.isConditional = this.getBoolean();
    } else {
        this.minecartEid = this.getEntityRuntimeId();
    }
    this.command = this.getString();
    this.lastOutput = this.getString();
    this.name = this.getString();
    this.shouldTrackOutput = this.getBoolean();
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Example 8 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class NewJungleTree method generate.

@Override
public boolean generate(ChunkManager worldIn, NukkitRandom rand, Vector3 vectorPosition) {
    BlockVector3 position = new BlockVector3(vectorPosition.getFloorX(), vectorPosition.getFloorY(), vectorPosition.getFloorZ());
    int i = rand.nextBoundedInt(3) + this.minTreeHeight;
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 <= 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;
            if (j == position.getY()) {
                k = 0;
            }
            if (j >= position.getY() + 1 + i - 2) {
                k = 2;
            }
            BlockVector3 pos2 = new BlockVector3();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        pos2.setComponents(l, j, i1);
                        if (!this.canGrowInto(worldIn.getBlockIdAt(pos2.x, pos2.y, pos2.z))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            BlockVector3 down = position.down();
            int block = worldIn.getBlockIdAt(down.x, down.y, down.z);
            if ((block == Block.GRASS || block == Block.DIRT || block == Block.FARMLAND) && position.getY() < 256 - i - 1) {
                this.setDirtAt(worldIn, down);
                int k2 = 3;
                int l2 = 0;
                for (int i3 = position.getY() - 3 + i; i3 <= position.getY() + i; ++i3) {
                    int i4 = i3 - (position.getY() + i);
                    int j1 = 1 - i4 / 2;
                    for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) {
                        int l1 = k1 - position.getX();
                        for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) {
                            int j2 = i2 - position.getZ();
                            if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextBoundedInt(2) != 0 && i4 != 0) {
                                BlockVector3 blockpos = new BlockVector3(k1, i3, i2);
                                int id = worldIn.getBlockIdAt(blockpos.x, blockpos.y, blockpos.z);
                                if (id == Block.AIR || id == Block.LEAVES || id == Block.VINE) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
                                }
                            }
                        }
                    }
                }
                for (int j3 = 0; j3 < i; ++j3) {
                    BlockVector3 up = position.up(j3);
                    int id = worldIn.getBlockIdAt(up.x, up.y, up.z);
                    if (id == Block.AIR || id == Block.LEAVES || id == Block.VINE) {
                        this.setBlockAndNotifyAdequately(worldIn, up, this.metaWood);
                        if (j3 > 0) {
                            if (rand.nextBoundedInt(3) > 0 && isAirBlock(worldIn, position.add(-1, j3, 0))) {
                                this.addVine(worldIn, position.add(-1, j3, 0), 8);
                            }
                            if (rand.nextBoundedInt(3) > 0 && isAirBlock(worldIn, position.add(1, j3, 0))) {
                                this.addVine(worldIn, position.add(1, j3, 0), 2);
                            }
                            if (rand.nextBoundedInt(3) > 0 && isAirBlock(worldIn, position.add(0, j3, -1))) {
                                this.addVine(worldIn, position.add(0, j3, -1), 1);
                            }
                            if (rand.nextBoundedInt(3) > 0 && isAirBlock(worldIn, position.add(0, j3, 1))) {
                                this.addVine(worldIn, position.add(0, j3, 1), 4);
                            }
                        }
                    }
                }
                for (int k3 = position.getY() - 3 + i; k3 <= position.getY() + i; ++k3) {
                    int j4 = k3 - (position.getY() + i);
                    int k4 = 2 - j4 / 2;
                    BlockVector3 pos2 = new BlockVector3();
                    for (int l4 = position.getX() - k4; l4 <= position.getX() + k4; ++l4) {
                        for (int i5 = position.getZ() - k4; i5 <= position.getZ() + k4; ++i5) {
                            pos2.setComponents(l4, k3, i5);
                            if (worldIn.getBlockIdAt(pos2.x, pos2.y, pos2.z) == Block.LEAVES) {
                                BlockVector3 blockpos2 = pos2.west();
                                BlockVector3 blockpos3 = pos2.east();
                                BlockVector3 blockpos4 = pos2.north();
                                BlockVector3 blockpos1 = pos2.south();
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos2.x, blockpos2.y, blockpos2.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos2, 8);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos3.x, blockpos3.y, blockpos3.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos3, 2);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos4.x, blockpos4.y, blockpos4.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos4, 1);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos1.x, blockpos1.y, blockpos1.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos1, 4);
                                }
                            }
                        }
                    }
                }
                if (rand.nextBoundedInt(5) == 0 && i > 5) {
                    for (int l3 = 0; l3 < 2; ++l3) {
                        for (BlockFace enumfacing : BlockFace.Plane.HORIZONTAL) {
                            if (rand.nextBoundedInt(4 - l3) == 0) {
                                BlockFace enumfacing1 = enumfacing.getOpposite();
                                this.placeCocoa(worldIn, rand.nextBoundedInt(3), position.add(enumfacing1.getXOffset(), i - 5 + l3, enumfacing1.getZOffset()), enumfacing);
                            }
                        }
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}
Also used : BlockFace(cn.nukkit.math.BlockFace) BlockVector3(cn.nukkit.math.BlockVector3)

Example 9 with BlockVector3

use of cn.nukkit.math.BlockVector3 in project Nukkit by Nukkit.

the class ObjectSwampTree method generate.

@Override
public boolean generate(ChunkManager worldIn, NukkitRandom rand, Vector3 vectorPosition) {
    BlockVector3 position = new BlockVector3(vectorPosition.getFloorX(), vectorPosition.getFloorY(), vectorPosition.getFloorZ());
    int i = rand.nextBoundedInt(4) + 5;
    boolean flag = true;
    if (position.getY() >= 1 && position.getY() + i + 1 <= 256) {
        for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) {
            int k = 1;
            if (j == position.getY()) {
                k = 0;
            }
            if (j >= position.getY() + 1 + i - 2) {
                k = 3;
            }
            BlockVector3 pos2 = new BlockVector3();
            for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) {
                for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) {
                    if (j >= 0 && j < 256) {
                        pos2.setComponents(l, j, i1);
                        if (!this.canGrowInto(worldIn.getBlockIdAt(pos2.x, pos2.y, pos2.z))) {
                            flag = false;
                        }
                    } else {
                        flag = false;
                    }
                }
            }
        }
        if (!flag) {
            return false;
        } else {
            BlockVector3 down = position.down();
            int block = worldIn.getBlockIdAt(down.x, down.y, down.z);
            if ((block == Block.GRASS || block == Block.DIRT) && position.getY() < 256 - i - 1) {
                this.setDirtAt(worldIn, down);
                for (int k1 = position.getY() - 3 + i; k1 <= position.getY() + i; ++k1) {
                    int j2 = k1 - (position.getY() + i);
                    int l2 = 2 - j2 / 2;
                    for (int j3 = position.getX() - l2; j3 <= position.getX() + l2; ++j3) {
                        int k3 = j3 - position.getX();
                        for (int i4 = position.getZ() - l2; i4 <= position.getZ() + l2; ++i4) {
                            int j1 = i4 - position.getZ();
                            if (Math.abs(k3) != l2 || Math.abs(j1) != l2 || rand.nextBoundedInt(2) != 0 && j2 != 0) {
                                BlockVector3 blockpos = new BlockVector3(j3, k1, i4);
                                int id = worldIn.getBlockIdAt(blockpos.x, blockpos.y, blockpos.z);
                                if (id == Block.AIR || id == Block.LEAVES || id == Block.VINE) {
                                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves);
                                }
                            }
                        }
                    }
                }
                for (int l1 = 0; l1 < i; ++l1) {
                    BlockVector3 up = position.up(l1);
                    int id = worldIn.getBlockIdAt(up.x, up.y, up.z);
                    if (id == Block.AIR || id == Block.LEAVES || id == Block.WATER || id == Block.STILL_WATER) {
                        this.setBlockAndNotifyAdequately(worldIn, up, this.metaWood);
                    }
                }
                for (int i2 = position.getY() - 3 + i; i2 <= position.getY() + i; ++i2) {
                    int k2 = i2 - (position.getY() + i);
                    int i3 = 2 - k2 / 2;
                    BlockVector3 pos2 = new BlockVector3();
                    for (int l3 = position.getX() - i3; l3 <= position.getX() + i3; ++l3) {
                        for (int j4 = position.getZ() - i3; j4 <= position.getZ() + i3; ++j4) {
                            pos2.setComponents(l3, i2, j4);
                            if (worldIn.getBlockIdAt(pos2.x, pos2.y, pos2.z) == Block.LEAVES) {
                                BlockVector3 blockpos2 = pos2.west();
                                BlockVector3 blockpos3 = pos2.east();
                                BlockVector3 blockpos4 = pos2.north();
                                BlockVector3 blockpos1 = pos2.south();
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos2.x, blockpos2.y, blockpos2.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos2, 8);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos3.x, blockpos3.y, blockpos3.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos3, 2);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos4.x, blockpos4.y, blockpos4.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos4, 1);
                                }
                                if (rand.nextBoundedInt(4) == 0 && worldIn.getBlockIdAt(blockpos1.x, blockpos1.y, blockpos1.z) == Block.AIR) {
                                    this.addHangingVine(worldIn, blockpos1, 4);
                                }
                            }
                        }
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    } else {
        return false;
    }
}
Also used : BlockVector3(cn.nukkit.math.BlockVector3)

Aggregations

BlockVector3 (cn.nukkit.math.BlockVector3)9 Item (cn.nukkit.item.Item)1 BlockFace (cn.nukkit.math.BlockFace)1