Search in sources :

Example 61 with Vec3i

use of net.minecraft.util.math.Vec3i in project OreSpawn by MinecraftModDevelopmentMods.

the class DefaultFeatureGenerator method spawnOre.

private void spawnOre(World world, ISpawnEntry spawnData, BlockPos pos, int quantity) {
    int count = quantity;
    int lutType = (quantity < 8) ? offsetIndexRef_small.length : offsetIndexRef.length;
    int[] lut = (quantity < 8) ? offsetIndexRef_small : offsetIndexRef;
    Vec3i[] offs = new Vec3i[lutType];
    System.arraycopy((quantity < 8) ? offsets_small : offsets, 0, offs, 0, lutType);
    if (quantity < 27) {
        int[] scrambledLUT = new int[lutType];
        System.arraycopy(lut, 0, scrambledLUT, 0, scrambledLUT.length);
        scramble(scrambledLUT, this.random);
        while (count > 0) {
            IBlockState oreBlock = spawnData.getBlocks().getRandomBlock(random);
            BlockPos target = pos.add(offs[scrambledLUT[--count]]);
            spawn(oreBlock, world, target, world.provider.getDimension(), true, spawnData);
        }
        return;
    }
    doSpawnFill(this.random.nextBoolean(), count, world, spawnData, pos);
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Example 62 with Vec3i

use of net.minecraft.util.math.Vec3i in project Random-Things by lumien231.

the class WorldUtil method getEntitiesWithinAABBs.

public static List getEntitiesWithinAABBs(World worldObj, Class clazz, Predicate filter, AxisAlignedBB... bbs) {
    ArrayList arraylist = new ArrayList();
    HashMap<Vec3i, ArrayList<AxisAlignedBB>> boxMap = new HashMap<>();
    for (AxisAlignedBB bb : bbs) {
        int minChunkX = MathHelper.floor((bb.minX - World.MAX_ENTITY_RADIUS) / 16.0D);
        int maxChunkX = MathHelper.floor((bb.maxX + World.MAX_ENTITY_RADIUS) / 16.0D);
        int minChunkZ = MathHelper.floor((bb.minZ - World.MAX_ENTITY_RADIUS) / 16.0D);
        int maxChunkZ = MathHelper.floor((bb.maxZ + World.MAX_ENTITY_RADIUS) / 16.0D);
        int minChunkY = MathHelper.floor((bb.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
        int maxChunkY = MathHelper.floor((bb.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
        for (int x = minChunkX; x <= maxChunkX; x++) {
            for (int z = minChunkZ; z <= maxChunkZ; z++) {
                for (int y = minChunkY; y <= maxChunkY; y++) {
                    if (y >= 0 && y < worldObj.getHeight() / 16) {
                        Vec3i chunkVec = new Vec3i(x, y, z);
                        ArrayList<AxisAlignedBB> boxList = boxMap.get(chunkVec);
                        if (boxList == null) {
                            boxList = new ArrayList<>();
                            boxMap.put(chunkVec, boxList);
                        }
                        boxList.add(bb);
                    }
                }
            }
        }
    }
    for (Vec3i chunkVec : boxMap.keySet()) {
        Chunk chunk = worldObj.getChunkFromChunkCoords(chunkVec.getX(), chunkVec.getZ());
        ClassInheritanceMultiMap[] entityMapArray = chunk.getEntityLists();
        Iterator<Entity> iterator = entityMapArray[chunkVec.getY()].getByClass(clazz).iterator();
        while (iterator.hasNext()) {
            Entity entity = iterator.next();
            for (AxisAlignedBB bb : boxMap.get(chunkVec)) {
                if (entity.getEntityBoundingBox().intersects(bb) && (filter == null || filter.apply(entity))) {
                    arraylist.add(entity);
                    Entity[] entityParts = entity.getParts();
                    if (entityParts != null) {
                        for (int l = 0; l < entityParts.length; ++l) {
                            entity = entityParts[l];
                            if (entity.getEntityBoundingBox().intersects(bb) && (filter == null || filter.apply(entity))) {
                                arraylist.add(entity);
                            }
                        }
                    }
                }
            }
        }
    }
    return arraylist;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) Entity(net.minecraft.entity.Entity) ClassInheritanceMultiMap(net.minecraft.util.ClassInheritanceMultiMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Chunk(net.minecraft.world.chunk.Chunk)

Example 63 with Vec3i

use of net.minecraft.util.math.Vec3i in project Random-Things by lumien231.

the class RenderAncientFurnace method render.

@Override
public void render(TileEntityAncientFurnace te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    STATE state = te.getState();
    int counter = te.getStartingCounter();
    float transparency = 0;
    if (state == STATE.RUNNING) {
        transparency = 1;
    } else if (state == STATE.STARTING && counter > 100) {
        transparency = Math.min(1, -1 * (float) Math.cos(((counter + partialTicks) - 100) / 300D * (Math.PI / 2)) + 1);
    }
    if (state == STATE.RUNNING || (state == STATE.STARTING && counter > 100)) {
        // System.out.println(transparency + "/" + counter);
        // transparency = 0.1f;
        GlStateManager.alphaFunc(GL11.GL_ALWAYS, 0);
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
        this.setLightmapDisabled(true);
        GlStateManager.disableLighting();
        float yellow = ((float) Math.sin((RTEventHandler.clientAnimationCounter + partialTicks) / 25f) + 1) / 5 + 0.1f;
        GlStateManager.color(1f, yellow, 0, transparency);
        for (Overlay o : toDraw) {
            Pair<Integer, Integer> offset = o.offset;
            long rdm = MathHelper.getPositionRandom(new Vec3i(te.getPos().getX() + offset.getLeft(), te.getPos().getY(), te.getPos().getZ() + offset.getRight()));
            int model = getRandomInteger(4, Math.abs((int) rdm >> 16) % 4);
            for (EnumFacing f : o.facings) {
                ResourceLocation texture = textures[textureIndices[model][f.getHorizontalIndex()]];
                this.bindTexture(texture);
                Tessellator tessellator = Tessellator.getInstance();
                BufferBuilder renderer = tessellator.getBuffer();
                renderer.begin(7, DefaultVertexFormats.POSITION_TEX);
                double iX = x + offset.getLeft();
                double iZ = z + offset.getRight();
                switch(f) {
                    case NORTH:
                        renderer.pos(iX, y, iZ - 0.001).tex(1, 1).endVertex();
                        renderer.pos(iX, y + 1, iZ - 0.001).tex(1, 0).endVertex();
                        renderer.pos(iX + 1, y + 1, iZ - 0.001).tex(0, 0).endVertex();
                        renderer.pos(iX + 1, y, iZ - 0.001).tex(0, 1).endVertex();
                        break;
                    case SOUTH:
                        renderer.pos(iX, y, iZ + 1.001).tex(0, 1).endVertex();
                        renderer.pos(iX + 1, y, iZ + 1.001).tex(1, 1).endVertex();
                        renderer.pos(iX + 1, y + 1, iZ + 1.001).tex(1, 0).endVertex();
                        renderer.pos(iX, y + 1, iZ + 1.001).tex(0, 0).endVertex();
                        break;
                    case WEST:
                        renderer.pos(iX - 0.001, y, iZ).tex(0, 1).endVertex();
                        renderer.pos(iX - 0.001, y, iZ + 1).tex(1, 1).endVertex();
                        renderer.pos(iX - 0.001, y + 1, iZ + 1).tex(1, 0).endVertex();
                        renderer.pos(iX - 0.001, y + 1, iZ).tex(0, 0).endVertex();
                        break;
                    case EAST:
                        renderer.pos(iX + 1.001, y, iZ).tex(1, 1).endVertex();
                        renderer.pos(iX + 1.001, y + 1, iZ).tex(1, 0).endVertex();
                        renderer.pos(iX + 1.001, y + 1, iZ + 1).tex(0, 0).endVertex();
                        renderer.pos(iX + 1.001, y, iZ + 1).tex(0, 1).endVertex();
                        break;
                    default:
                        break;
                }
                tessellator.draw();
            }
        }
        this.setLightmapDisabled(false);
        GlStateManager.enableLighting();
        GlStateManager.disableBlend();
        GlStateManager.alphaFunc(516, 0.1F);
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) EnumFacing(net.minecraft.util.EnumFacing) BufferBuilder(net.minecraft.client.renderer.BufferBuilder) STATE(lumien.randomthings.tileentity.TileEntityAncientFurnace.STATE) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 64 with Vec3i

use of net.minecraft.util.math.Vec3i in project RecurrentComplex by Ivorforce.

the class CommandNaturalSpace method placeNaturalAir.

public static void placeNaturalAir(MockWorld world, BlockArea area, int floorDistance, int maxClosedSides) {
    BlockGenericSpace spaceBlock = RCBlocks.genericSpace;
    BlockPos lowerPoint = area.getLowerCorner();
    BlockPos higherPoint = area.getHigherCorner();
    Set<BlockPos> set = new HashSet<>();
    for (BlockSurfacePos surfaceCoord : BlockSurfaceArea.from(area)) {
        int safePoint = lowerPoint.getY();
        for (int y = higherPoint.getY(); y >= lowerPoint.getY(); y--) {
            IBlockState blockState = world.getBlockState(surfaceCoord.blockPos(y));
            if ((blockState.getMaterial() != Material.AIR && blockState.getBlock() != spaceBlock) || sidesClosed(world, surfaceCoord.blockPos(y), area) >= maxClosedSides) {
                boolean isFloor = blockState == RCBlocks.genericSolid.getDefaultState();
                safePoint = y + (isFloor ? 1 : floorDistance);
                break;
            }
        }
        for (int y = safePoint; y <= higherPoint.getY(); y++) set.add(surfaceCoord.blockPos(y));
        if (safePoint > lowerPoint.getY()) {
            for (int y = lowerPoint.getY(); y <= higherPoint.getY(); y++) {
                IBlockState blockState = world.getBlockState(surfaceCoord.blockPos(y));
                if ((blockState.getMaterial() != Material.AIR && blockState.getBlock() != spaceBlock) || sidesClosed(world, surfaceCoord.blockPos(y), area) >= maxClosedSides) {
                    safePoint = y - 1;
                    break;
                }
            }
        }
        for (int y = lowerPoint.getY(); y <= safePoint; y++) set.add(surfaceCoord.blockPos(y));
    }
    set.forEach(pos -> {
        BlockPos down = pos.down();
        BlockPos down2 = pos.down(2);
        world.setBlockState(pos, pos.getY() > lowerPoint.getY() && !set.contains(down) && world.getBlockState(down).getBlock().isReplaceable(world, down) && world.getBlockState(down2).getBlock().isReplaceable(world, down2) && new BlockArea(pos.subtract(new Vec3i(2, 0, 2)), pos.add(new Vec3i(2, 0, 2))).stream().allMatch(set::contains) ? spaceBlock.getDefaultState().withProperty(BlockGenericSpace.TYPE, 1) : spaceBlock.getDefaultState());
    });
}
Also used : BlockArea(ivorius.ivtoolkit.blocks.BlockArea) Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) BlockGenericSpace(ivorius.reccomplex.block.BlockGenericSpace) BlockSurfacePos(ivorius.ivtoolkit.blocks.BlockSurfacePos) BlockPos(net.minecraft.util.math.BlockPos) HashSet(java.util.HashSet)

Example 65 with Vec3i

use of net.minecraft.util.math.Vec3i in project RecurrentComplex by Ivorforce.

the class MazeVisualizationContext method max.

public BlockPos max(MazeRoom room) {
    int[] one = new int[room.getDimensions()];
    Arrays.fill(one, 1);
    return apply(IvVecMathHelper.add(room.getCoordinates(), one)).subtract(new Vec3i(1, 1, 1));
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)65 BlockPos (net.minecraft.util.math.BlockPos)35 IBlockState (net.minecraft.block.state.IBlockState)15 World (net.minecraft.world.World)12 EnumFacing (net.minecraft.util.EnumFacing)7 IBeeModifier (forestry.api.apiculture.IBeeModifier)6 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 Tessellator (net.minecraft.client.renderer.Tessellator)4 Vec3d (net.minecraft.util.math.Vec3d)4 Random (java.util.Random)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 EnumTemperature (forestry.api.core.EnumTemperature)2 ICheckPollinatable (forestry.api.genetics.ICheckPollinatable)2 EffectLightning (hellfirepvp.fracture.client.effect.fx.EffectLightning)2 EntityFXFacingParticle (hellfirepvp.fracture.client.effect.fx.EntityFXFacingParticle)2 FissureData (hellfirepvp.fracture.common.fissure.FissureData)2 Vector3 (hellfirepvp.fracture.common.util.Vector3)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2