Search in sources :

Example 61 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project Hyperium by HyperiumClient.

the class ReachDisplay method attacc.

@InvokeEvent
public void attacc(PlayerAttackEntityEvent entityEvent) {
    if (!Settings.SHOW_HIT_DISTANCES)
        return;
    if (!(entityEvent.getEntity() instanceof EntityLivingBase))
        return;
    if (((EntityLivingBase) entityEvent.getEntity()).hurtTime > 0)
        return;
    if (locked)
        return;
    locked = true;
    EntityPlayerSP entity = Minecraft.getMinecraft().thePlayer;
    double d0 = 6;
    Vec3 vec3 = entity.getPositionEyes(0.0F);
    Vec3 vec31 = entity.getLook(0.0F);
    Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
    Entity entity1 = entityEvent.getEntity();
    float f1 = .1F;
    AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand(f1, f1, f1);
    MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
    if (movingobjectposition == null)
        return;
    Vec3 vec33 = movingobjectposition.hitVec;
    hits.add(new Hit(vec33, dis));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) Entity(net.minecraft.entity.Entity) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Vec3(net.minecraft.util.Vec3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 62 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project LogisticsPipes by RS485.

the class LogisticsBlockGenericPipe method getSelectedBoundingBoxFromPool.

@Override
@SideOnly(Side.CLIENT)
public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int x, int y, int z) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof PipeBlockRequestTable) {
        return AxisAlignedBB.getBoundingBox(x + 0.0, y + 0.0, z + 0.0, x + 1.0, y + 1.0, z + 1.0);
    }
    RaytraceResult rayTraceResult = null;
    if (bypassPlayerTrace == null) {
        rayTraceResult = doRayTrace(world, x, y, z, Minecraft.getMinecraft().thePlayer);
    } else {
        rayTraceResult = bypassPlayerTrace;
    }
    if (rayTraceResult != null && rayTraceResult.boundingBox != null) {
        AxisAlignedBB box = rayTraceResult.boundingBox;
        switch(rayTraceResult.hitPart) {
            case Pluggable:
                {
                    float scale = 0.001F;
                    box = box.expand(scale, scale, scale);
                    break;
                }
            case Pipe:
                {
                    float scale = 0.001F;
                    box = box.expand(scale, scale, scale);
                    break;
                }
        }
        return box.getOffsetBoundingBox(x, y, z);
    }
    return super.getSelectedBoundingBoxFromPool(world, x, y, z).expand(-0.85F, -0.85F, -0.85F);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 63 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project LogisticsPipes by RS485.

the class LogisticsBlockGenericSubMultiBlock method addCollisionBoxesToList.

@SuppressWarnings("rawtypes")
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB axisalignedbb, List arraylist, Entity entity) {
    DoubleCoordinates pos = new DoubleCoordinates(x, y, z);
    TileEntity tile = pos.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> mainPipeList = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        mainPipeList.stream().filter(mainPipe -> mainPipe != null && mainPipe.pipe != null && mainPipe.pipe.isMultiBlock()).forEach(mainPipe -> LogisticsPipes.LogisticsPipeBlock.addCollisionBoxesToList(world, mainPipe.xCoord, mainPipe.yCoord, mainPipe.zCoord, axisalignedbb, arraylist, entity));
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsPipes(logisticspipes.LogisticsPipes) Random(java.util.Random) MainProxy(logisticspipes.proxy.MainProxy) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) Block(net.minecraft.block.Block) MovingObjectPosition(net.minecraft.util.MovingObjectPosition) Minecraft(net.minecraft.client.Minecraft) LPConstants(logisticspipes.LPConstants) IBlockAccess(net.minecraft.world.IBlockAccess) Vec3(net.minecraft.util.Vec3) Entity(net.minecraft.entity.Entity) BlockContainer(net.minecraft.block.BlockContainer) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) EffectRenderer(net.minecraft.client.particle.EffectRenderer) World(net.minecraft.world.World) EntityDiggingFX(net.minecraft.client.particle.EntityDiggingFX) AxisAlignedBB(net.minecraft.util.AxisAlignedBB) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) IIcon(net.minecraft.util.IIcon) List(java.util.List) Material(net.minecraft.block.material.Material) EntityPlayer(net.minecraft.entity.player.EntityPlayer) TileEntity(net.minecraft.tileentity.TileEntity) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 64 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project LogisticsPipes by RS485.

the class HSTubeSpeedup method addCollisionBoxesToList.

@Override
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
    DoubleCoordinates pos = getLPPosition();
    DoubleCoordinates posMin = new DoubleCoordinates(LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS, LPConstants.PIPE_MIN_POS);
    DoubleCoordinates posMax = new DoubleCoordinates(LPConstants.PIPE_MAX_POS, LPConstants.PIPE_MAX_POS, -3);
    orientation.rotatePositions(posMin);
    orientation.rotatePositions(posMax);
    if (orientation == SpeedupDirection.EAST) {
        pos.add(new DoubleCoordinates(1, 0, 0));
    } else if (orientation == SpeedupDirection.SOUTH) {
        pos.add(new DoubleCoordinates(1, 0, 1));
    } else if (orientation == SpeedupDirection.WEST) {
        pos.add(new DoubleCoordinates(0, 0, 1));
    }
    posMin.add(pos);
    posMax.add(pos);
    LPPositionSet<DoubleCoordinates> set = new LPPositionSet<>(DoubleCoordinates.class);
    set.add(posMin);
    set.add(posMax);
    AxisAlignedBB box = set.toABB();
    if (box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))) {
        arraylist.add(box);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 65 with AxisAlignedBB

use of net.minecraft.util.AxisAlignedBB in project LogisticsPipes by RS485.

the class HSTubeGain method addCollisionBoxesToList.

@Override
public void addCollisionBoxesToList(List arraylist, AxisAlignedBB axisalignedbb) {
    if (boxes == null || boxes.isEmpty()) {
        boxes = new ArrayList<>();
        double x = getX();
        double y = getY();
        double z = getZ();
        for (int i = -1; i < 54; i++) {
            double xOne = x;
            double yOne = y;
            double zOne = z;
            double xTwo = x;
            double yTwo = y + 2;
            double zTwo = z;
            if (orientation.getRenderOrientation() == TubeGainRenderOrientation.SOUTH) {
                zOne += 4.0F * (i - 4) / 50;
                zTwo += 4.0F * (i + 4) / 50;
                xOne += 1;
                xTwo -= 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.WEST) {
                xOne -= 3;
                xTwo -= 3;
                xOne += 4.0F * (i - 4) / 50;
                xTwo += 4.0F * (i + 4) / 50;
                zOne -= 1;
                zTwo += 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.NORTH) {
                zOne += 1;
                zTwo += 1;
                zOne -= 4.0F * (i - 4) / 50;
                zTwo -= 4.0F * (i + 4) / 50;
                xOne -= 1;
                xTwo += 2;
            } else if (orientation.getRenderOrientation() == TubeGainRenderOrientation.EAST) {
                xOne += 4;
                xTwo += 4;
                xOne -= 4.0F * (i - 4) / 50;
                xTwo -= 4.0F * (i + 4) / 50;
                zOne -= 1;
                zTwo += 2;
            }
            AxisAlignedBB box = GainTubeRenderer.getObjectBoundsAt(AxisAlignedBB.getBoundingBox(Math.min(xOne, xTwo), Math.min(yOne, yTwo), Math.min(zOne, zTwo), Math.max(xOne, xTwo), Math.max(yOne, yTwo), Math.max(zOne, zTwo)).getOffsetBoundingBox(-x, -y, -z), orientation);
            if (box != null) {
                LPPositionSet<DoubleCoordinates> lpBox = new LPPositionSet<>(DoubleCoordinates.class);
                lpBox.addFrom(box);
                DoubleCoordinates center = lpBox.getCenter();
                box = AxisAlignedBB.getBoundingBox(center.getXCoord() - 0.3D, center.getYCoord() - 0.3D, center.getZCoord() - 0.3D, center.getXCoord() + 0.3D, center.getYCoord() + 0.3D, center.getZCoord() + 0.3D);
                if (box != null) {
                    AxisAlignedBB cBox = getCompleteBox();
                    if (box.minX < cBox.minX) {
                        box.minX = cBox.minX;
                    }
                    if (box.minY < cBox.minY) {
                        box.minY = cBox.minY;
                    }
                    if (box.minZ < cBox.minZ) {
                        box.minZ = cBox.minZ;
                    }
                    if (box.maxX > cBox.maxX) {
                        box.maxX = cBox.maxX;
                    }
                    if (box.maxY > cBox.maxY) {
                        box.maxY = cBox.maxY;
                    }
                    if (box.maxZ > cBox.maxZ) {
                        box.maxZ = cBox.maxZ;
                    }
                    box = box.getOffsetBoundingBox(x, y, z);
                    boxes.add(box);
                }
            }
        }
    }
    arraylist.addAll(boxes.stream().filter(box -> box != null && (axisalignedbb == null || axisalignedbb.intersectsWith(box))).collect(Collectors.toList()));
}
Also used : AxisAlignedBB(net.minecraft.util.AxisAlignedBB) LPPositionSet(logisticspipes.utils.LPPositionSet) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

AxisAlignedBB (net.minecraft.util.AxisAlignedBB)123 Entity (net.minecraft.entity.Entity)40 EntityPlayer (net.minecraft.entity.player.EntityPlayer)28 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)24 TileEntity (net.minecraft.tileentity.TileEntity)20 Vec3 (net.minecraft.util.Vec3)20 ArrayList (java.util.ArrayList)16 ItemStack (net.minecraft.item.ItemStack)16 List (java.util.List)15 Block (net.minecraft.block.Block)15 EntityLivingBase (net.minecraft.entity.EntityLivingBase)15 EntityItem (net.minecraft.entity.item.EntityItem)13 SideOnly (cpw.mods.fml.relauncher.SideOnly)10 World (net.minecraft.world.World)7 Pos (com.builtbroken.mc.imp.transform.vector.Pos)6 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)6 Iterator (java.util.Iterator)5 BlockPos (net.minecraft.util.BlockPos)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)4 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)4