Java Code Examples for cn.nukkit.math.Vector3#add()

The following examples show how to use cn.nukkit.math.Vector3#add() . 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: HugeTreesGenerator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 2
Source File: HugeTreesGenerator.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle
 */
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 3
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 4
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 5
Source File: BlockEndPortalFrame.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void createPortal() {
    Vector3 centerSpot = this.searchCenter();
    if(centerSpot != null) {
        for(int x = -2; x <= 2; x++) {
            for(int z = -2; z <= 2; z++) {
                if((x == -2 || x == 2) && (z == -2 || z == 2))
                    continue;
                if(x == -2 || x == 2 || z == -2 || z == 2) {
                    if(!this.checkFrame(this.getLevel().getBlock(centerSpot.add(x, 0, z)), x, z)) {
                        return;
                    }
                }
            }
        }

        for(int x = -1; x <= 1; x++) {
            for(int z = -1; z <= 1; z++) {
                Vector3 vector3 = centerSpot.add(x, 0, z);
                if(this.getLevel().getBlock(vector3).getId() != Block.AIR) {
                    this.getLevel().useBreakOn(vector3);
                }
                this.getLevel().setBlock(vector3, Block.get(Block.END_PORTAL));
            }
        }
    }
}
 
Example 6
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j) {
        for (int k = -width; k <= width + 1; ++k) {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 7
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * grow leaves in a circle
 */
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;

    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
Example 8
Source File: HugeTreesGenerator.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * returns whether or not there is space for a tree to grow at a certain position
 */
private boolean isSpaceAt(ChunkManager worldIn, Vector3 leavesPos, int height) {
    boolean flag = true;

    if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) {
        for (int i = 0; i <= 1 + height; ++i) {
            int j = 2;

            if (i == 0) {
                j = 1;
            } else if (i >= 1 + height - 2) {
                j = 2;
            }

            for (int k = -j; k <= j && flag; ++k) {
                for (int l = -j; l <= j && flag; ++l) {
                    Vector3 blockPos = leavesPos.add(k, i, l);
                    if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.canGrowInto(worldIn.getBlockIdAt((int) blockPos.x, (int) blockPos.y, (int) blockPos.z))) {
                        flag = false;
                    }
                }
            }
        }

        return flag;
    } else {
        return false;
    }
}
 
Example 9
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private boolean isSpaceAt(ChunkManager worldIn, Vector3 leavesPos, int height) {
    boolean flag = true;

    if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) {
        for (int i = 0; i <= 1 + height; ++i) {
            int j = 2;

            if (i == 0) {
                j = 1;
            } else if (i >= 1 + height - 2) {
                j = 2;
            }

            for (int k = -j; k <= j && flag; ++k) {
                for (int l = -j; l <= j && flag; ++l) {
                    Vector3 blockPos = leavesPos.add(k, i, l);
                    if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.canGrowInto(worldIn.getBlockIdAt((int) blockPos.x, (int) blockPos.y, (int) blockPos.z))) {
                        flag = false;
                    }
                }
            }
        }

        return flag;
    } else {
        return false;
    }
}
 
Example 10
Source File: HugeTreesGenerator.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * returns whether or not there is space for a tree to grow at a certain position
 */
private boolean isSpaceAt(ChunkManager worldIn, Vector3 leavesPos, int height) {
    boolean flag = true;

    if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) {
        for (int i = 0; i <= 1 + height; ++i) {
            int j = 2;

            if (i == 0) {
                j = 1;
            } else if (i >= 1 + height - 2) {
                j = 2;
            }

            for (int k = -j; k <= j && flag; ++k) {
                for (int l = -j; l <= j && flag; ++l) {
                    Vector3 blockPos = leavesPos.add(k, i, l);
                    if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.canGrowInto(worldIn.getBlockIdAt((int) blockPos.x, (int) blockPos.y, (int) blockPos.z))) {
                        flag = false;
                    }
                }
            }
        }

        return flag;
    } else {
        return false;
    }
}