Search in sources :

Example 1 with TileMarkerVolume

use of buildcraft.core.tile.TileMarkerVolume in project BuildCraft by BuildCraft.

the class BlockMarkerVolume method checkSignalState.

private static void checkSignalState(World world, BlockPos pos) {
    if (world.isRemote) {
        return;
    }
    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileMarkerVolume) {
        TileMarkerVolume volume = (TileMarkerVolume) tile;
        boolean powered = world.isBlockPowered(pos);
        if (volume.isShowingSignals() != powered) {
            volume.switchSignals();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMarkerVolume(buildcraft.core.tile.TileMarkerVolume)

Example 2 with TileMarkerVolume

use of buildcraft.core.tile.TileMarkerVolume 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)

Example 3 with TileMarkerVolume

use of buildcraft.core.tile.TileMarkerVolume in project BuildCraft by BuildCraft.

the class BlockMarkerVolume method onBlockActivated.

@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!world.isRemote) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileMarkerVolume) {
            TileMarkerVolume volume = (TileMarkerVolume) tile;
            volume.onManualConnectionAttempt(player);
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileMarkerVolume(buildcraft.core.tile.TileMarkerVolume)

Aggregations

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