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;
}
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();
}
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();
}
Aggregations