Search in sources :

Example 41 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityBreakerSwitch method onDirectionalPlacement.

@Override
public void onDirectionalPlacement(EnumFacing side, float hitX, float hitY, float hitZ, EntityLivingBase placer) {
    EnumFacing f = EnumFacing.SOUTH;
    if (side.getAxis() == Axis.Y) {
        float xFromMid = hitX - .5f;
        float zFromMid = hitZ - .5f;
        float max = Math.max(Math.abs(xFromMid), Math.abs(zFromMid));
        if (max == Math.abs(xFromMid))
            f = xFromMid < 0 ? EnumFacing.WEST : EnumFacing.EAST;
        else
            f = zFromMid < 0 ? EnumFacing.NORTH : EnumFacing.SOUTH;
        if ((side == EnumFacing.UP && f.getAxis() == Axis.Z) || side == EnumFacing.DOWN)
            f = f.getOpposite();
    }
    rotation = f.getHorizontalIndex();
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Example 42 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityBreakerSwitch method notifyNeighbours.

public void notifyNeighbours() {
    markDirty();
    worldObj.notifyNeighborsOfStateChange(getPos(), getBlockType());
    for (EnumFacing f : EnumFacing.VALUES) worldObj.notifyNeighborsOfStateChange(getPos().offset(f), getBlockType());
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Example 43 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityBreakerSwitch method calculateLeftConn.

protected void calculateLeftConn(Matrix4 transform) {
    Vec3d leftVec = transform.apply(new Vec3d(-1, .5, .5)).subtract(0, .5, .5);
    EnumFacing dir = EnumFacing.getFacingFromVector((float) leftVec.xCoord, (float) leftVec.yCoord, (float) leftVec.zCoord);
    int maxDiff = Integer.MIN_VALUE;
    Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
    if (conns != null)
        for (Connection c : conns) {
            Vec3i diff = pos.equals(c.start) ? c.end.subtract(pos) : c.start.subtract(pos);
            int val = 0;
            switch(dir.getAxis()) {
                case X:
                    val = diff.getX();
                    break;
                case Y:
                    val = diff.getY();
                    break;
                case Z:
                    val = diff.getZ();
            }
            val *= dir.getAxisDirection().getOffset();
            if (val > maxDiff) {
                maxDiff = val;
                endOfLeftConnection = pos == c.end ? c.start : c.end;
            }
        }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) EnumFacing(net.minecraft.util.EnumFacing) Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) Vec3d(net.minecraft.util.math.Vec3d)

Example 44 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityBottlingMachine method getBlockBounds.

@Override
public float[] getBlockBounds() {
    if (pos == 4)
        return new float[] { 0, 0, 0, 1, .5f, 1 };
    if (pos < 6 || pos == 11)
        return new float[] { 0, 0, 0, 1, 1, 1 };
    if (pos >= 6 && pos <= 8)
        return new float[] { 0, 0, 0, 1, .125f, 1 };
    if (pos == 9)
        return new float[] { .0625f, 0, .0625f, .9375f, 1, .9375f };
    if (pos == 10) {
        EnumFacing f = mirrored ? facing.rotateYCCW() : facing.rotateY();
        float xMin = f == EnumFacing.EAST ? -.0625f : f == EnumFacing.WEST ? .25f : facing == EnumFacing.WEST ? .125f : facing == EnumFacing.EAST ? .25f : 0;
        float zMin = facing == EnumFacing.NORTH ? .125f : facing == EnumFacing.SOUTH ? .25f : f == EnumFacing.SOUTH ? -.0625f : f == EnumFacing.NORTH ? .25f : 0;
        float xMax = f == EnumFacing.EAST ? .75f : f == EnumFacing.WEST ? 1.0625f : facing == EnumFacing.WEST ? .75f : facing == EnumFacing.EAST ? .875f : 1;
        float zMax = facing == EnumFacing.NORTH ? .75f : facing == EnumFacing.SOUTH ? .875f : f == EnumFacing.SOUTH ? .75f : f == EnumFacing.NORTH ? 1.0625f : 1;
        return new float[] { xMin, .0625f, zMin, xMax, .6875f, zMax };
    }
    if (pos == 13) {
        float xMin = facing == EnumFacing.WEST ? 0 : .21875f;
        float zMin = facing == EnumFacing.NORTH ? 0 : .21875f;
        float xMax = facing == EnumFacing.EAST ? 1 : .78125f;
        float zMax = facing == EnumFacing.SOUTH ? 1 : .78125f;
        return new float[] { xMin, -.4375f, zMin, xMax, .5625f, zMax };
    }
    if (pos == 16) {
        float xMin = facing == EnumFacing.WEST ? .8125f : facing == EnumFacing.EAST ? 0 : .125f;
        float zMin = facing == EnumFacing.NORTH ? .8125f : facing == EnumFacing.SOUTH ? 0 : .125f;
        float xMax = facing == EnumFacing.WEST ? 1 : facing == EnumFacing.EAST ? .1875f : .875f;
        float zMax = facing == EnumFacing.NORTH ? 1 : facing == EnumFacing.SOUTH ? .1875f : .875f;
        return new float[] { xMin, -1, zMin, xMax, .25f, zMax };
    }
    return new float[] { 0, 0, 0, 1, 1, 1 };
}
Also used : EnumFacing(net.minecraft.util.EnumFacing)

Example 45 with EnumFacing

use of net.minecraft.util.EnumFacing in project ImmersiveEngineering by BluSunrize.

the class TileEntityConnectorRedstone method getConnectionOffset.

@Override
public Vec3d getConnectionOffset(Connection con) {
    EnumFacing side = facing.getOpposite();
    double conRadius = con.cableType.getRenderDiameter() / 2;
    return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

EnumFacing (net.minecraft.util.EnumFacing)260 BlockPos (net.minecraft.util.math.BlockPos)94 TileEntity (net.minecraft.tileentity.TileEntity)64 IBlockState (net.minecraft.block.state.IBlockState)57 Block (net.minecraft.block.Block)35 ItemStack (net.minecraft.item.ItemStack)24 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)23 Vec3d (net.minecraft.util.math.Vec3d)16 ArrayList (java.util.ArrayList)15 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)10 IFluidHandler (net.minecraftforge.fluids.capability.IFluidHandler)10 World (net.minecraft.world.World)9 Tessellator (net.minecraft.client.renderer.Tessellator)8 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)8 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)7 List (java.util.List)6 EntityLivingBase (net.minecraft.entity.EntityLivingBase)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)6 Nonnull (javax.annotation.Nonnull)5