Search in sources :

Example 1 with VolumeConnection

use of buildcraft.core.marker.VolumeConnection in project BuildCraft by BuildCraft.

the class TileMarkerVolume method isValidFromLocation.

@Override
public boolean isValidFromLocation(BlockPos pos) {
    VolumeConnection connection = getCurrentConnection();
    if (connection == null) {
        return false;
    }
    Box box = connection.getBox();
    if (box.contains(pos)) {
        return false;
    }
    for (BlockPos p : PositionUtil.getCorners(box.min(), box.max())) {
        if (PositionUtil.isNextTo(p, pos)) {
            return true;
        }
    }
    return false;
}
Also used : VolumeConnection(buildcraft.core.marker.VolumeConnection) Box(buildcraft.lib.misc.data.Box) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with VolumeConnection

use of buildcraft.core.marker.VolumeConnection in project BuildCraft by BuildCraft.

the class RenderMarkerVolume method render.

@Override
public void render(TileMarkerVolume marker, double tileX, double tileY, double tileZ, float partialTicks, int destroyStage, float alpha) {
    if (marker == null || !marker.isShowingSignals())
        return;
    Minecraft.getMinecraft().mcProfiler.startSection("bc");
    Minecraft.getMinecraft().mcProfiler.startSection("marker");
    Minecraft.getMinecraft().mcProfiler.startSection("volume");
    DetachedRenderer.fromWorldOriginPre(Minecraft.getMinecraft().player, partialTicks);
    RenderHelper.disableStandardItemLighting();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    VolumeConnection volume = marker.getCurrentConnection();
    Set<Axis> taken = volume == null ? ImmutableSet.of() : volume.getConnectedAxis();
    Vec3d start = VecUtil.add(VEC_HALF, marker.getPos());
    for (EnumFacing face : EnumFacing.VALUES) {
        if (taken.contains(face.getAxis())) {
            continue;
        }
        Vec3d end = VecUtil.offset(start, face, BCCoreConfig.markerMaxDistance);
        renderLaser(start, end, face.getAxis());
    }
    RenderHelper.enableStandardItemLighting();
    DetachedRenderer.fromWorldOriginPost();
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
    Minecraft.getMinecraft().mcProfiler.endSection();
}
Also used : VolumeConnection(buildcraft.core.marker.VolumeConnection) EnumFacing(net.minecraft.util.EnumFacing) Axis(net.minecraft.util.EnumFacing.Axis) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with VolumeConnection

use of buildcraft.core.marker.VolumeConnection in project BuildCraft by BuildCraft.

the class TileQuarry method onPlacedBy.

@Override
public void onPlacedBy(EntityLivingBase placer, ItemStack stack) {
    super.onPlacedBy(placer, stack);
    if (placer.world.isRemote) {
        return;
    }
    EnumFacing facing = world.getBlockState(pos).getValue(BlockBCBase_Neptune.PROP_FACING);
    BlockPos areaPos = pos.offset(facing.getOpposite());
    TileEntity tile = world.getTileEntity(areaPos);
    BlockPos min = null, max = null;
    if (tile instanceof IAreaProvider) {
        IAreaProvider provider = (IAreaProvider) tile;
        min = provider.min();
        max = provider.max();
        int dx = max.getX() - min.getX();
        int dz = max.getZ() - min.getZ();
        if (dx < 3 || dz < 3) {
            min = null;
            max = null;
        } else {
            provider.removeFromWorld();
        }
    }
    // noinspection ConstantConditions
    if (min == null || max == null) {
        min = null;
        max = null;
        VolumeSubCache cache = VolumeCache.INSTANCE.getSubCache(getWorld());
        for (BlockPos markerPos : cache.getAllMarkers()) {
            TileMarkerVolume marker = (TileMarkerVolume) cache.getMarker(markerPos);
            if (marker == null) {
                continue;
            }
            VolumeConnection connection = marker.getCurrentConnection();
            if (connection == null) {
                continue;
            }
            Box volBox = connection.getBox();
            Box box2 = new Box();
            box2.initialize(volBox);
            if (!box2.isInitialized()) {
                continue;
            }
            if (pos.getY() != box2.min().getY()) {
                continue;
            }
            if (box2.contains(pos)) {
                continue;
            }
            if (!box2.contains(areaPos)) {
                continue;
            }
            if (box2.size().getX() < 3 || box2.size().getZ() < 3) {
                continue;
            }
            box2.expand(1);
            box2.setMin(box2.min().up());
            if (box2.isOnEdge(pos)) {
                min = volBox.min();
                max = volBox.max();
                marker.removeFromWorld();
                break;
            }
        }
    }
    if (min == null || max == null) {
        miningBox.reset();
        frameBox.reset();
        switch(facing.getOpposite()) {
            case DOWN:
            case UP:
            default:
            case // +X
            EAST:
                min = pos.add(1, 0, -5);
                max = pos.add(11, 4, 5);
                break;
            case // -X
            WEST:
                min = pos.add(-11, 0, -5);
                max = pos.add(-1, 4, 5);
                break;
            case // +Z
            SOUTH:
                min = pos.add(-5, 0, 1);
                max = pos.add(5, 4, 11);
                break;
            case // -Z
            NORTH:
                min = pos.add(-5, 0, -11);
                max = pos.add(5, 4, -1);
                break;
        }
    }
    if (max.getY() - min.getY() < 4) {
        max = new BlockPos(max.getX(), min.getY() + 4, max.getZ());
    }
    frameBox.reset();
    frameBox.setMin(min);
    frameBox.setMax(max);
    miningBox.reset();
    miningBox.setMin(new BlockPos(min.getX() + 1, 0, min.getZ() + 1));
    miningBox.setMax(new BlockPos(max.getX() - 1, max.getY() - 1, max.getZ() - 1));
    updatePoses();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IAreaProvider(buildcraft.api.core.IAreaProvider) TileMarkerVolume(buildcraft.core.tile.TileMarkerVolume) VolumeConnection(buildcraft.core.marker.VolumeConnection) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Box(buildcraft.lib.misc.data.Box) VolumeSubCache(buildcraft.core.marker.VolumeSubCache)

Aggregations

VolumeConnection (buildcraft.core.marker.VolumeConnection)3 Box (buildcraft.lib.misc.data.Box)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 IAreaProvider (buildcraft.api.core.IAreaProvider)1 VolumeSubCache (buildcraft.core.marker.VolumeSubCache)1 TileMarkerVolume (buildcraft.core.tile.TileMarkerVolume)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Axis (net.minecraft.util.EnumFacing.Axis)1 Vec3d (net.minecraft.util.math.Vec3d)1