Java 类net.minecraft.util.math.Vec3i 实例源码

项目:RunicArcana    文件:DustSymbolProjection.java   
public static Vec3i viewToFaceVec(Vec3d viewVector, double length)
{
    //normalize vector so we can work with it better
    viewVector = viewVector.normalize();
    int majorAxis = 0;
    if(Math.abs(viewVector.yCoord)>=Math.abs(viewVector.xCoord) && Math.abs(viewVector.yCoord)>=Math.abs(viewVector.zCoord)) majorAxis=1;
    else if(Math.abs(viewVector.zCoord)>=Math.abs(viewVector.xCoord) && Math.abs(viewVector.zCoord)>=Math.abs(viewVector.yCoord)) majorAxis=2;
    length = Math.round(length);

    switch(majorAxis)
    {
        case 0:
            return new Vec3i(Math.signum(viewVector.xCoord)*length,0,0);
        case 1:
            return new Vec3i(0,Math.signum(viewVector.yCoord)*length,0);
        case 2:
            return new Vec3i(0,0,Math.signum(viewVector.zCoord)*length);
        default:
            break;

    }

    return new Vec3i(1,0,0);
}
项目:ArcaneMagic    文件:EntityItemFancy.java   
@Override
public void move(MoverType type, double x, double y, double z)
{
    if (this.freezeTime <= 0)
    {
        Vec3i oldPos = new Vec3i((int) Math.floor(this.getPosition().getX()),
                (int) Math.floor(this.getPosition().getY()), (int) Math.floor(this.getPosition().getZ()));
        super.move(type, x, y, z);
        Vec3i newPos = new Vec3i((int) Math.floor(this.getPosition().getX()),
                (int) Math.floor(this.getPosition().getY()), (int) Math.floor(this.getPosition().getZ()));
        if (!oldPos.equals(newPos))
        {
            if (world.getBlockState(new BlockPos(oldPos)).getBlock() == ModRegistry.FANCY_LIGHT)
            {
                world.setBlockToAir(new BlockPos(oldPos));
            }

            if (world.getBlockState(new BlockPos(newPos)).getBlock() == Blocks.AIR)
            {
                world.setBlockState(new BlockPos(newPos), ModRegistry.FANCY_LIGHT.getDefaultState());
            }
        }
    } else
    {
    }
}
项目:Zombe-Modpack    文件:Safe.java   
@Override
protected void onWorldDraw(float delta, float x, float y, float z) {
    float mx, my, mz;
    if (!safeShow) return;
    if (--safeUpdate < 0) {
        safeUpdate = 13;
        reCheckSafe(fix(x), fix(y), fix(z));
    }
    if (safeGhost) GL11.glDisable(GL11.GL_DEPTH_TEST);
    else           GL11.glEnable( GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < safeCur; ++i) {
        Vec3i pos   = safePoses[i];
        Color color = safeMarks[i];
        GL11.glColor3ub(color.rb, color.gb, color.bb);
        mx = pos.getX() - x; my = pos.getY() - y; mz = pos.getZ() - z;
        GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.9f);
        GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.1f);
        GL11.glVertex3f(mx+0.9f,my+0.01f,mz+0.1f);
        GL11.glVertex3f(mx+0.1f,my+0.01f,mz+0.9f);
    }
    GL11.glEnd();
}
项目:Backmemed    文件:BlockModelRenderer.java   
private void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads)
{
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;

    for (int j = listQuads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());

        if (bakedquad.hasTintIndex())
        {
            vertexbuffer.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
        }
        else
        {
            vertexbuffer.putColorRGB_F4(brightness, brightness, brightness);
        }

        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        tessellator.draw();
    }
}
项目:CustomWorldGen    文件:BlockModelRenderer.java   
private void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads)
{
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;

    for (int j = listQuads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());

        if (bakedquad.hasTintIndex())
        {
            vertexbuffer.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
        }
        else
        {
            vertexbuffer.putColorRGB_F4(brightness, brightness, brightness);
        }

        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        tessellator.draw();
    }
}
项目:ExPetrum    文件:GenerationHelper.java   
public static EnumRockClass getStoneTypeAt(World w, BlockPos at)
{
    if (lastRememberedSeed != w.getSeed())
    {
        rand.setSeed(w.getSeed());
        offsetStone = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
        offsetDirt = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
    }

    BlockPos actual = at.add(offsetStone);

    try
    {
        FeatureProvider provider = ((BiomeProviderExP)w.getBiomeProvider()).featureProvider;
        return EnumRockClass.values()[Math.abs(provider.getByte(actual, provider.cacheRocks)) % 16];
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
        return EnumRockClass.ANDESITE;
    }
}
项目:ExPetrum    文件:GenerationHelper.java   
public static EnumDirtClass getDirtTypeAt(World w, BlockPos at)
{
    if (lastRememberedSeed != w.getSeed())
    {
        rand.setSeed(w.getSeed());
        offsetStone = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
        offsetDirt = new Vec3i(rand.nextInt(300000) - rand.nextInt(300000), 0, rand.nextInt(300000) - rand.nextInt(300000));
    }

    BlockPos actual = at.add(offsetDirt);

    try
    {
        FeatureProvider provider = ((BiomeProviderExP)w.getBiomeProvider()).featureProvider;
        return EnumDirtClass.values()[Math.abs(provider.getByte(actual, provider.cacheSoil)) % 16];
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
        return EnumDirtClass.ACRISOL;
    }
}
项目:Qbar    文件:MultiblockComponent.java   
public Iterable<BlockPos> getAllInBox(BlockPos pos, final EnumFacing facing)
{
    Iterable<BlockPos> searchables = null;

    pos = pos.add(this.getCoreOffset(facing));
    if (facing.getAxis() == Axis.Z)
        searchables = BlockPos.getAllInBox(
                pos.subtract(new Vec3i(this.getOffsetX(), this.getOffsetY(), this.getOffsetZ())),
                pos.add(this.getWidth() - 1 - this.getOffsetX(), this.getHeight() - 1 - this.getOffsetY(),
                        this.getLength() - 1 - this.getOffsetZ()));
    else
        searchables = BlockPos.getAllInBox(
                pos.subtract(new Vec3i(this.getOffsetZ(), this.getOffsetY(), this.getOffsetX())),
                pos.add(this.getLength() - 1 - this.getOffsetZ(), this.getHeight() - 1 - this.getOffsetY(),
                        this.getWidth() - 1 - this.getOffsetX()));
    return searchables;
}
项目:Alchemy    文件:EntityAIEatMeat.java   
@Override
public boolean shouldExecute() {
    if (living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > living.ticksExisted)
        living.getEntityData().setInteger(NBT_KEY_LAST_MEAL, -Time.DAY);
    PathNavigate navigate = living.getNavigator();
    if (living.getHealth() < living.getMaxHealth() || living.ticksExisted - living.getEntityData().getInteger(NBT_KEY_LAST_MEAL) > Time.DAY) {
        List<EntityItem> list = living.world.getEntitiesWithinAABB(EntityItem.class, AABBHelper.getAABBFromEntity(living, 32), this);
        list.sort(this);
        for (int i = list.size() - 1; i > -1; i--) {
            EntityItem item = list.get(i);
            navigate.tryMoveToEntityLiving(item, 1);
            Path path = navigate.getPath();
            if (path != null) {
                PathPoint point = path.getFinalPathPoint();
                if (item.getPosition().distanceSq(new Vec3i(point.x, point.y, point.z)) < 2) {
                    meat = item;
                    return true;
                }
            }
        }
    }
    return false;
}
项目:Hard-Science    文件:CubicQuadPainter.java   
/** 
 * Rotates given surface vector around the center of the texture by the given degree.
 * 
 */
protected static Vec3i rotateFacePerspective(Vec3i vec, Rotation rotation, TextureScale scale)
{
    switch(rotation)
    {
    case ROTATE_90:
        return new Vec3i(vec.getY(), scale.sliceCountMask - vec.getX(), vec.getZ());

    case ROTATE_180:
        return new Vec3i(scale.sliceCountMask - vec.getX(), scale.sliceCountMask - vec.getY(), vec.getZ());

    case ROTATE_270:
        return new Vec3i(scale.sliceCountMask - vec.getY(), vec.getX(), vec.getZ());

    case ROTATE_NONE:
    default:
        return vec;

    }
}
项目:Hard-Science    文件:CubicQuadPainter.java   
protected CubicQuadPainter(ModelState modelState, Surface surface, PaintLayer paintLayer)
{
    super(modelState, surface, paintLayer);

    this.species = modelState.hasSpecies() ? modelState.getSpecies() : 0;

    int x = modelState.getPosX();
    int y = modelState.getPosY();
    int z  = modelState.getPosZ();
    this.pos = new Vec3i(x, y, z);

    int shift = this.texture.textureScale.power;

    int speciesBits = species << 16;

    int xBits = (((y >> shift) & 0xFF) << 8) | ((z >> shift) & 0xFF) | speciesBits;
    int yBits = (((x >> shift) & 0xFF) << 8) | ((z >> shift) & 0xFF) | speciesBits;
    int zBits = (((x >> shift) & 0xFF) << 8) | ((y >> shift) & 0xFF) | speciesBits;

    this.variationHashX = MathHelper.hash(xBits);
    this.variationHashY = MathHelper.hash(yBits);
    this.variationHashZ = MathHelper.hash(zBits);
}
项目:Hard-Science    文件:PerChunkBlockPosQueue.java   
public int sizeInChunksNear(BlockPos pos, int chunkRadius)
{
    int result = 0;

    int i = 0;
    Vec3i offset = Useful.getDistanceSortedCircularOffset(i);

    while(offset.getY() <= chunkRadius)
    {
        result += sizeInChunkAt(pos.add(offset.getX() * 16, 0, offset.getZ() * 16));
        offset = Useful.getDistanceSortedCircularOffset(++i);

    }

    return result;
}
项目:Hard-Science    文件:ChunkMap.java   
public Iterator<T> existingChunksNear(BlockPos pos, int chunkRadius)
{
    return new AbstractIterator<T>()
    {
        private int i = 0;

        @Override
        protected T computeNext()
        {
            Vec3i offset = Useful.getDistanceSortedCircularOffset(i++);

            while(offset != null && offset.getY() <= chunkRadius)
            {
                T result = getIfExists(pos.add(offset.getX() * 16, 0, offset.getZ() * 16));
                if(result != null) return result;
                offset = Useful.getDistanceSortedCircularOffset(i++);
            }

            return (T)this.endOfData();
        }

    };

}
项目:Hard-Science    文件:VoxelBitField.java   
public void setOrigin(int x, int y, int z)
{
    this.origin = new Vec3i(clamp(x), clamp(y), clamp(z));
    this.distances = new ArrayList<DistanceRankedVoxel>(getBitsPerAxis() * getBitsPerAxis() * getBitsPerAxis());
    this.firstDistanceIndex = 0;

    for(int i = 0; i < getBitsPerAxis(); i++)
    {
        for(int j = 0; j < getBitsPerAxis(); j++)
        {
            for(int k = 0; k < getBitsPerAxis(); k++)
            {
                DistanceRankedVoxel point = new DistanceRankedVoxel(i, j, k, origin);
                this.distances.add(point);
            }
        }
    }
    this.distances.sort(DistanceComparator.INSTANCE);
}
项目:enderutilities    文件:TaskStackArea.java   
public TaskStackArea(World world, UUID wandUUID, BlockPos posOrig, BlockPos endPosRelative,
        TemplateEnderUtilities template, Area3D area, int blocksPerTick)
{
    this.dimension = world.provider.getDimension();
    this.wandUUID = wandUUID;
    this.posOrig = posOrig;
    this.sizeAbs = new Vec3i(Math.abs(endPosRelative.getX()) + 1, Math.abs(endPosRelative.getY()) + 1, Math.abs(endPosRelative.getZ()) + 1);
    this.template = template;
    this.templateNumBlocks = template.getBlockList().size();
    this.area = area;
    this.blocksPerTick = blocksPerTick;
    this.currentArea = new Vec3i(-area.getXNeg(), -area.getYNeg(), -area.getZNeg());

    if (this.currentArea.getX() == 0 && this.currentArea.getY() == 0 && this.currentArea.getZ() == 0)
    {
        this.incrementArea();
    }

    this.currentStartPos = this.getStartPos();
}
项目:ExpandedRailsMod    文件:BlockModelRenderer.java   
private void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads)
{
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;

    for (int j = listQuads.size(); i < j; ++i)
    {
        BakedQuad bakedquad = (BakedQuad)listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());

        if (bakedquad.hasTintIndex())
        {
            vertexbuffer.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
        }
        else
        {
            vertexbuffer.putColorRGB_F4(brightness, brightness, brightness);
        }

        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        tessellator.draw();
    }
}
项目:OpenBlocks    文件:AdapterVillageHighlighter.java   
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get information about the villages this block is inside")
public Map<?, ?> getVillages(TileEntityVillageHighlighter vh) {
    Map<Integer, Object> map = Maps.newHashMap();
    int i = 1;
    for (Village village : vh.getWorld().villageCollection.getVillageList()) {
        if (village.isBlockPosWithinSqVillageRadius(vh.getPos())) {
            Map<String, Object> villageMap = Maps.newHashMap();
            Vec3i d = village.getCenter().subtract(vh.getPos());
            villageMap.put("x", d.getX());
            villageMap.put("y", d.getY());
            villageMap.put("z", d.getZ());
            villageMap.put("doors", village.getNumVillageDoors());
            villageMap.put("villagers", village.getNumVillagers());
            villageMap.put("radius", village.getVillageRadius());
            map.put(i++, villageMap);
        }
    }
    return map;
}
项目:Zombe-Modpack    文件:Safe.java   
@Override
protected void init() {
    safePoses = new Vec3i[SAFE_MAX];
    safeMarks = new Color[SAFE_MAX];
    safeCur = 0;
    safeUpdate = 0;
    safeShow = false;
    safeGhost = false;
}
项目:Zombe-Modpack    文件:Safe.java   
private void reCheckSafe(int pX, int pY, int pZ) {
    safeCur = 0;
    for (int x = pX-optLookupRadius; x <= pX+optLookupRadius; ++x)
    for (int y = pY-optLookupRadius; y <= pY+optLookupRadius; ++y)
    for (int z = pZ-optLookupRadius; z <= pZ+optLookupRadius; ++z) {
        if (couldSpawnHere(x,y,z)) {
            safePoses[safeCur] = new Vec3i(x,y,z);
            safeMarks[safeCur] = (optShowWithSun && getSkyLightLevel(x,y,z) > 7) ? optDangerColorSun : optDangerColor;
            ++safeCur;
            if (safeCur == SAFE_MAX) return;
        }
    }
}
项目:Backmemed    文件:StructureBoundingBox.java   
public StructureBoundingBox(Vec3i vec1, Vec3i vec2)
{
    this.minX = Math.min(vec1.getX(), vec2.getX());
    this.minY = Math.min(vec1.getY(), vec2.getY());
    this.minZ = Math.min(vec1.getZ(), vec2.getZ());
    this.maxX = Math.max(vec1.getX(), vec2.getX());
    this.maxY = Math.max(vec1.getY(), vec2.getY());
    this.maxZ = Math.max(vec1.getZ(), vec2.getZ());
}
项目:Backmemed    文件:BlockPattern.java   
/**
 * Offsets the position of pos in the direction of finger and thumb facing by offset amounts, follows the right-hand
 * rule for cross products (finger, thumb, palm) @return A new BlockPos offset in the facing directions
 */
protected static BlockPos translateOffset(BlockPos pos, EnumFacing finger, EnumFacing thumb, int palmOffset, int thumbOffset, int fingerOffset)
{
    if (finger != thumb && finger != thumb.getOpposite())
    {
        Vec3i vec3i = new Vec3i(finger.getFrontOffsetX(), finger.getFrontOffsetY(), finger.getFrontOffsetZ());
        Vec3i vec3i1 = new Vec3i(thumb.getFrontOffsetX(), thumb.getFrontOffsetY(), thumb.getFrontOffsetZ());
        Vec3i vec3i2 = vec3i.crossProduct(vec3i1);
        return pos.add(vec3i1.getX() * -thumbOffset + vec3i2.getX() * palmOffset + vec3i.getX() * fingerOffset, vec3i1.getY() * -thumbOffset + vec3i2.getY() * palmOffset + vec3i.getY() * fingerOffset, vec3i1.getZ() * -thumbOffset + vec3i2.getZ() * palmOffset + vec3i.getZ() * fingerOffset);
    }
    else
    {
        throw new IllegalArgumentException("Invalid forwards & up combination");
    }
}
项目:CustomWorldGen    文件:TRSRTransformation.java   
public static EnumFacing rotate(Matrix4f matrix, EnumFacing facing)
{
    Vec3i dir = facing.getDirectionVec();
    Vector4f vec = new Vector4f(dir.getX(), dir.getY(), dir.getZ(), 0);
    matrix.transform(vec);
    return EnumFacing.getFacingFromVector(vec.x, vec.y, vec.z);
}
项目:CustomWorldGen    文件:StructureBoundingBox.java   
public StructureBoundingBox(Vec3i vec1, Vec3i vec2)
{
    this.minX = Math.min(vec1.getX(), vec2.getX());
    this.minY = Math.min(vec1.getY(), vec2.getY());
    this.minZ = Math.min(vec1.getZ(), vec2.getZ());
    this.maxX = Math.max(vec1.getX(), vec2.getX());
    this.maxY = Math.max(vec1.getY(), vec2.getY());
    this.maxZ = Math.max(vec1.getZ(), vec2.getZ());
}
项目:CustomWorldGen    文件:BlockPattern.java   
/**
 * Offsets the position of pos in the direction of finger and thumb facing by offset amounts, follows the right-hand
 * rule for cross products (finger, thumb, palm) @return A new BlockPos offset in the facing directions
 */
protected static BlockPos translateOffset(BlockPos pos, EnumFacing finger, EnumFacing thumb, int palmOffset, int thumbOffset, int fingerOffset)
{
    if (finger != thumb && finger != thumb.getOpposite())
    {
        Vec3i vec3i = new Vec3i(finger.getFrontOffsetX(), finger.getFrontOffsetY(), finger.getFrontOffsetZ());
        Vec3i vec3i1 = new Vec3i(thumb.getFrontOffsetX(), thumb.getFrontOffsetY(), thumb.getFrontOffsetZ());
        Vec3i vec3i2 = vec3i.crossProduct(vec3i1);
        return pos.add(vec3i1.getX() * -thumbOffset + vec3i2.getX() * palmOffset + vec3i.getX() * fingerOffset, vec3i1.getY() * -thumbOffset + vec3i2.getY() * palmOffset + vec3i.getY() * fingerOffset, vec3i1.getZ() * -thumbOffset + vec3i2.getZ() * palmOffset + vec3i.getZ() * fingerOffset);
    }
    else
    {
        throw new IllegalArgumentException("Invalid forwards & up combination");
    }
}
项目:CustomWorldGen    文件:FaceBakery.java   
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
项目:ModularMachinery    文件:BlockArray.java   
public BlockArray(BlockArray other, Vec3i offset) {
    for (Map.Entry<BlockPos, BlockInformation> otherEntry : other.pattern.entrySet()) {
        this.pattern.put(otherEntry.getKey().add(offset), otherEntry.getValue());
    }
    this.min = new Vec3i(other.min.getX(), other.min.getY(), other.min.getZ());
    this.max = new Vec3i(other.max.getX(), other.max.getY(), other.max.getZ());
    this.size = new Vec3i(other.size.getX(), other.size.getY(), other.size.getZ());
}
项目:runesofwizardry-classics    文件:ClassicRune.java   
@Override
public Vec3i getEntityPosition() {
    if(Config.cacheRuneInfo){
        if(entityPos==null){
            entityPos = setupEntityPos();
        }
        return entityPos;
    }else{
        return setupEntityPos();
    }
}
项目:CrystalMod    文件:CustomModelUtil.java   
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z);
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f(vec3i.getX(), vec3i.getY(), vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
项目:AquaRegia    文件:VectorUtils.java   
/**
 * Create a matrix that rotates around the specified axis by the specified angle.
 *
 * @param axis    The axis
 * @param radians The angle in radians
 * @return The rotation matrix
 */
public static Matrix3d getRotationMatrix(EnumFacing.Axis axis, double radians) {
    final Vec3i axisDirectionVector = AXIS_DIRECTION_VECTORS.get(axis);
    final AxisAngle4d axisAngle = new AxisAngle4d(axisDirectionVector.getX(), axisDirectionVector.getY(), axisDirectionVector.getZ(), radians);

    final Matrix3d rotationMatrix = new Matrix3d();
    rotationMatrix.set(axisAngle);

    return rotationMatrix;
}
项目:Gravestone-mod-Extended    文件:GraveGenerationHelper.java   
public static EntityGroupOfGravesMobSpawnerHelper createSpawnerHelper(World world, StructureBoundingBox boundingBox) {
    EntityGroupOfGravesMobSpawnerHelper spawnerHelper = new EntityGroupOfGravesMobSpawnerHelper(world);

    Vec3i center = boundingBox.getLength();
    spawnerHelper.setLocationAndAngles(center.getX(), center.getY(), center.getZ(), 0, 0);
    world.spawnEntity(spawnerHelper);

    return spawnerHelper;
}
项目:DynamicSurroundings    文件:AreaSurveyHandler.java   
public Cell(@Nonnull final Vec3i offset, final int range) {
    this.offset = offset;
    final float xV = range - MathStuff.abs(offset.getX()) + 1;
    final float zV = range - MathStuff.abs(offset.getZ()) + 1;
    final float candidate = Math.min(xV, zV);
    this.points = candidate * candidate;
    this.working = new BlockPos.MutableBlockPos();
}
项目:malmo    文件:BuildBattleDecoratorImplementation.java   
/**
 * Attempt to parse the given object as a set of parameters for this handler.
 *
 * @param params the parameter block to parse
 * @return true if the object made sense for this handler; false otherwise.
 */
@Override
public boolean parseParameters(Object params)
{
    if (params == null || !(params instanceof BuildBattleDecorator))
        return false;

    this.params = (BuildBattleDecorator) params;

    this.sourceBounds = this.params.getGoalStructureBounds();
    this.destBounds = this.params.getPlayerStructureBounds();
    this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(),
                           destBounds.getMin().getY() - sourceBounds.getMin().getY(),
                           destBounds.getMin().getZ() - sourceBounds.getMin().getZ());

    this.structureVolume = volumeOfBounds(this.sourceBounds);
    assert(this.structureVolume == volumeOfBounds(this.destBounds));
    this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));
    this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null));

    DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
    DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();

    this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
    this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
    return true;
}
项目:Engination    文件:BlockConveyor.java   
private void shootPlayer(World world, BlockPos pos, Entity ent) {
    if (!(ent instanceof EntityPlayer)) return;

    IBlockState state = world.getBlockState(pos);
    EnumFacing facing = state.getValue(PROPERTY_FACING);
    Vec3i vec = facing.getDirectionVec();
    //double scale = 1.2d;
    Vec3d motion = new Vec3d(vec.getX()*scale, vec.getY()*scale, vec.getZ()*scale);

    ent.motionX = adjustScalar(ent.motionX, motion.x);
    ent.motionY = adjustScalar(ent.motionY, motion.y);
    ent.motionZ = adjustScalar(ent.motionZ, motion.z);
}
项目:pycode-minecraft    文件:ShapeGen.java   
public static void floor(World world, int width, int depth, IBlockState block_state, BlockPos pos, EnumFacing facing) {
    Vec3i front = facing.getDirectionVec();
    Vec3i side = facing.rotateY().getDirectionVec();
    for (int j = 0; j < width; j++) {
        BlockPos set = pos.add(side.getX() * j, 0, side.getZ() * j);
        for (int i = 0; i < depth; i++) {
            world.setBlockState(set, block_state);
            set = set.add(front);
        }
    }
}
项目:pycode-minecraft    文件:ShapeGen.java   
public static void wall(World world, int depth, int height, IBlockState block_state, BlockPos pos, EnumFacing facing) {
    Vec3i front = facing.getDirectionVec();
    for (int j = 0; j < height; j++) {
        BlockPos set = pos.add(0, j, 0);
        for (int i = 0; i < depth; i++) {
            world.setBlockState(set, block_state);
            set = set.add(front);
        }
    }
}
项目:LightningCraft    文件:Feature.java   
/**
 * current Position depends on currently set Coordinates mode, is computed here
 */
protected void placeBlockAtCurrentPosition(World world, Block b, int meta, int x, int y, int z, StructureBoundingBox box, boolean ignoreBox)
{
    int i1 = this.getXWithOffset(x, z);
    int j1 = this.getYWithOffset(y);
    int k1 = this.getZWithOffset(x, z);

    if (box.isVecInside(new Vec3i(i1, j1, k1)) || ignoreBox)
    {
        IBlockState state = b.getStateFromMeta(meta);
        world.setBlockState(new BlockPos(i1, j1, k1), state, 2);
    }
}
项目:RandomToolKit    文件:BlockFourierTransformer.java   
public boolean isConnected(World world, BlockPos from, BlockPos to){
    Vec3i diff = from.subtract(to);
    if(diff.getX() * diff.getZ() != 0)
        return false;

    return diff.getY() == 0 || !isBlockedDiagonal(world, from, to);
}
项目:NordMod    文件:TileAbstractEnergyCable.java   
@Override
public BlockPos getNeighborACoordinate(int index) {
    if (index > Facing.values().length) index = 0;
    Vec3i coord = Facing.values()[index].getDirectionVec();
    return new BlockPos(
            pos.getX() + coord.getX(),
            pos.getY() + coord.getY(),
            pos.getZ() + coord.getZ()
    );
}
项目:Hard-Science    文件:CubicQuadPainterBigTex.java   
/** 
 * Transform input vector so that x & y correspond with u / v on the given face, with u,v origin at upper left
 * and z is depth, where positive values represent distance into the face (away from viewer). <br><br>
 * 
 * Coordinates are start masked to the scale of the texture being used and when we reverse an orthogonalAxis, 
 * we use the texture's sliceMask as the basis so that we remain within the frame of the
 * texture scale we are using.  <br><br>
 * 
 * Note that the x, y components are for determining min/max UV values. 
 * They should NOT be used to set vertex UV coordinates directly.
 * All bigtex models should have lockUV = true, which means that 
 * uv coordinates will be derived at time of quad bake by projecting each
 * vertex onto the plane of the quad's nominal face. 
 * Setting UV coordinates on a quad with lockUV=true has no effect.
 */
protected static Vec3i getSurfaceVector(Vec3i vec, EnumFacing face, TextureScale scale)
{
    int sliceCountMask = scale.sliceCountMask;
    int x = vec.getX() & sliceCountMask;
    int y = vec.getY() & sliceCountMask;
    int z = vec.getZ() & sliceCountMask;

    switch(face)
    {
    case EAST:
        return new Vec3i(sliceCountMask - z, sliceCountMask - y, -vec.getX());

    case WEST:
        return new Vec3i(z, sliceCountMask - y, vec.getX());

    case NORTH:
        return new Vec3i(sliceCountMask - x, sliceCountMask - y, vec.getZ());

    case SOUTH:
        return new Vec3i(x, sliceCountMask - y, -vec.getZ());

    case DOWN:
        return new Vec3i(x, sliceCountMask - z, vec.getY());

    case UP:
    default:
        return new Vec3i(x, z, -vec.getY());
    }
}
项目:Hard-Science    文件:VolcanoTileEntity.java   
private void setBoreFlowEnabled(boolean enabled)
{
    LavaCells cells = Simulator.instance().lavaSimulator().cells;
    for(int i = 0; i < BORE_OFFSETS.size(); i++)
    {
        Vec3i offset = BORE_OFFSETS.get(i);
        LavaCell c = cells.getEntryCell(this.pos.getX() + offset.getX(), this.pos.getZ() + offset.getZ());
        if(c != null)
        {
            c.firstCell().setBoreCell(enabled);
        }
    }
}