Search in sources :

Example 66 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getBoundingBox.

@Deprecated
@Override
@SuppressWarnings("ConstantConditions")
public AxisAlignedBB getBoundingBox(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
    final EnumFacing facing = state.getValue(FACING);
    final AxisAlignedBB box = this.definition(facing).box(facing);
    return box != null ? box : super.getBoundingBox(state, world, pos);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing)

Example 67 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Almura by AlmuraDev.

the class HorizontalBlockImpl method getCollisionBoundingBox.

@Deprecated
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(final IBlockState state, final IBlockAccess world, final BlockPos pos) {
    final EnumFacing facing = state.getValue(FACING);
    final HorizontalBlockStateDefinition definition = this.definition(facing);
    if (definition.nullCollisionBox) {
        return null;
    }
    final AxisAlignedBB collisionBox = definition.collisionBox(facing);
    return collisionBox != null ? collisionBox : super.getCollisionBoundingBox(state, world, pos);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) HorizontalBlockStateDefinition(com.almuradev.content.type.block.type.horizontal.state.HorizontalBlockStateDefinition) Nullable(javax.annotation.Nullable)

Example 68 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Charset by CharsetMC.

the class BlockProjector method getBoundingBox.

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess world, BlockPos pos) {
    AxisAlignedBB base = BOUNDING_BOX;
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileProjector) {
        Quaternion quaternion = Quaternion.fromOrientation(((TileProjector) tile).getOrientation());
        base = quaternion.applyRotation(BOUNDING_BOX_ROTATE).offset(0.5, 0.5, 0.5);
    }
    return base;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntity(net.minecraft.tileentity.TileEntity) Quaternion(pl.asie.charset.lib.utils.Quaternion)

Example 69 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Charset by CharsetMC.

the class Wire method updateConnections.

protected void updateConnections() {
    if (!connectionCheckDirty) {
        return;
    }
    Set<WireFace> validSides = EnumSet.noneOf(WireFace.class);
    Set<WireFace> invalidCornerSides = EnumSet.noneOf(WireFace.class);
    for (WireFace facing : WireFace.VALUES) {
        if (facing == location) {
            continue;
        }
        if (facing != WireFace.CENTER && location != WireFace.CENTER && location.facing.getAxis() == facing.facing.getAxis()) {
            continue;
        }
        validSides.add(facing);
    }
    int oldConnectionCache = getConnectionMask();
    internalConnections = externalConnections = cornerConnections = occludedSides = cornerOccludedSides = 0;
    // Occlusion test
    EnumFacing[] connFaces = WireUtils.getConnectionsForRender(location);
    for (int i = 0; i < connFaces.length; i++) {
        WireFace face = WireFace.get(connFaces[i]);
        if (validSides.contains(face)) {
            boolean found = false;
            AxisAlignedBB mask = factory.getBox(location, i + 1);
            if (mask != null) {
                if (OcclusionUtils.INSTANCE.intersects(Collections.singletonList(mask), container.world(), container.pos())) {
                    occludedSides |= 1 << connFaces[i].ordinal();
                    validSides.remove(face);
                    found = true;
                }
            }
        /*
                if (!found && location != WireFace.CENTER) {
                    BlockPos cPos = container.pos().offset(connFaces[i]);
                    AxisAlignedBB cornerMask = factory.getCornerBox(location, i ^ 1);
                    if (cornerMask != null) {
                        if (OcclusionUtils.PRIMARY.intersects(Collections.singletonList(cornerMask), container.world(), cPos)) {
                            cornerOccludedSides |= 1 << connFaces[i].ordinal();
                            invalidCornerSides.add(face);
                        }
                    }
                } */
        }
    }
    if (validSides.contains(WireFace.CENTER)) {
        AxisAlignedBB mask = factory.getBox(WireFace.CENTER, 1 + location.ordinal());
        if (mask != null) {
            if (OcclusionUtils.INSTANCE.intersects(Collections.singletonList(mask), container.world(), container.pos())) {
                occludedSides |= 1 << 6;
                validSides.remove(WireFace.CENTER);
            }
        }
    }
    // Connection test
    for (WireFace facing : validSides) {
        if (WireUtils.canConnectInternal(this, facing)) {
            internalConnections |= 1 << facing.ordinal();
        } else if (facing != WireFace.CENTER) {
            if (WireUtils.canConnectExternal(this, facing.facing)) {
                externalConnections |= 1 << facing.ordinal();
            } else if (location != WireFace.CENTER && !invalidCornerSides.contains(facing) && WireUtils.canConnectCorner(this, facing.facing)) {
                cornerConnections |= 1 << facing.ordinal();
            }
        }
    }
    int newConnectionCache = getConnectionMask();
    if (oldConnectionCache != newConnectionCache) {
        container.requestNeighborUpdate(oldConnectionCache ^ newConnectionCache);
        container.requestRenderUpdate();
    }
    connectionCheckDirty = false;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EnumFacing(net.minecraft.util.EnumFacing) WireFace(pl.asie.charset.api.wires.WireFace)

Example 70 with AxisAlignedBB

use of net.minecraft.util.math.AxisAlignedBB in project Charset by CharsetMC.

the class BlockStacks method getBoundingBox.

@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
    TileEntity tile = source.getTileEntity(pos);
    if (tile instanceof TileEntityStacks) {
        int count = ((TileEntityStacks) tile).stacks.size();
        float height = ((count + 7) / 8) * 0.125f;
        return new AxisAlignedBB(0, 0, 0, 1, height, 1);
    } else {
        return FULL_BLOCK_AABB;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB)

Aggregations

AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)597 BlockPos (net.minecraft.util.math.BlockPos)194 Entity (net.minecraft.entity.Entity)133 EntityPlayer (net.minecraft.entity.player.EntityPlayer)119 IBlockState (net.minecraft.block.state.IBlockState)110 Vec3d (net.minecraft.util.math.Vec3d)95 EntityLivingBase (net.minecraft.entity.EntityLivingBase)93 EnumFacing (net.minecraft.util.EnumFacing)88 ItemStack (net.minecraft.item.ItemStack)77 World (net.minecraft.world.World)69 TileEntity (net.minecraft.tileentity.TileEntity)67 List (java.util.List)48 ArrayList (java.util.ArrayList)47 RayTraceResult (net.minecraft.util.math.RayTraceResult)45 EntityItem (net.minecraft.entity.item.EntityItem)43 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)41 Block (net.minecraft.block.Block)36 PotionEffect (net.minecraft.potion.PotionEffect)36 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 Nullable (javax.annotation.Nullable)24