use of net.minecraft.util.EnumFacing.AxisDirection in project BuildCraft by BuildCraft.
the class PipeModelCacheWire method generate.
private static ImmutableList<MutableQuad> generate(PipeWireKeySingle key) {
PipeWire wire = key.type;
Vec3d pos = wirePosMap.get(wire);
boolean isLit = key.on;
// BCLog.logger.info("generate[" + wire + ", " + isLit + ", " + key.connections + "]");
TextureAtlasSprite sprite = BuildCraftTransport.instance.wireIconProvider.getIcon(wire, isLit);
List<MutableQuad> unprocessed = new ArrayList<>();
Vec3d center = pos;
Vec3d centerSize = new Vec3d(WIRE_WIDTH, WIRE_WIDTH, WIRE_WIDTH);
AxisDirection[] directions = wireDirectionMap.get(wire);
int numFaces = 0;
for (EnumFacing face : EnumFacing.values()) {
boolean positive = face.getAxisDirection() == AxisDirection.POSITIVE;
Axis axis = face.getAxis();
AxisDirection wireCenter = directions[axis.ordinal()];
if (key.connections.contains(face)) {
if (wireCenter == face.getAxisDirection()) {
numFaces++;
}
numFaces++;
Vec3d start = pos;
Vec3d end = pos.add(centerSize);
if (positive) {
start = VecUtil.replaceValue(start, axis, VecUtil.getValue(start, axis) + WIRE_WIDTH);
end = VecUtil.replaceValue(end, axis, (double) 1);
} else {
start = VecUtil.replaceValue(start, axis, (double) 0);
end = VecUtil.replaceValue(end, axis, VecUtil.getValue(end, axis) - WIRE_WIDTH);
}
renderCuboid(unprocessed, start, end.subtract(start), sprite);
} else {
boolean anyOther = false;
for (EnumFacing face2 : EnumFacing.values()) {
if (face2.getOpposite() == face) {
continue;
}
anyOther |= key.connections.contains(face2);
}
if (anyOther) {
continue;
}
Vec3d start = pos;
Vec3d end = pos.add(centerSize);
if (positive) {
start = VecUtil.replaceValue(start, axis, VecUtil.getValue(start, axis) + WIRE_WIDTH);
end = VecUtil.replaceValue(end, axis, (double) CoreConstants.PIPE_MAX_POS);
} else {
start = VecUtil.replaceValue(start, axis, (double) CoreConstants.PIPE_MIN_POS);
end = VecUtil.replaceValue(end, axis, VecUtil.getValue(end, axis) - WIRE_WIDTH);
}
Vec3d size = end.subtract(start);
if (size.lengthVector() > WIRE_WIDTH * 2) {
renderCuboid(unprocessed, start, size, sprite);
}
}
}
if (numFaces != 1) {
renderCuboid(unprocessed, center, centerSize, sprite);
}
ImmutableList.Builder<MutableQuad> builder = ImmutableList.builder();
for (MutableQuad quad : unprocessed) {
if (isLit)
quad.lightf(1, 0);
quad.colourf(1, 1, 1, 1);
// quad.setCalculatedDiffuse();
builder.add(quad);
}
return builder.build();
}
use of net.minecraft.util.EnumFacing.AxisDirection in project BuildCraft by BuildCraft.
the class PipeModelCacheWire method getOffset.
private static Vec3d getOffset(PipeWire wire) {
double min = CoreConstants.PIPE_MIN_POS - WIRE_WIDTH;
double max = CoreConstants.PIPE_MAX_POS;
// Offset each wire slightly differently to avoid z-fighting between wires
int multiple = wire.ordinal() + 1;
double offset = WIRE_OFFSET * multiple;
double inset = -offset;
AxisDirection[] axis = wireDirectionMap.get(wire);
boolean[] axisPos = new boolean[3];
for (int i = 0; i < 3; i++) {
axisPos[i] = axis[i] == AxisDirection.POSITIVE;
}
Vec3d base = new Vec3d(axisPos[0] ? max : min, axisPos[1] ? max : min, axisPos[2] ? max : min);
return base.addVector(axisPos[0] ? inset : offset, axisPos[1] ? inset : offset, axisPos[2] ? inset : offset);
}
use of net.minecraft.util.EnumFacing.AxisDirection in project takumicraft by TNTModders.
the class BlockTakumiPortal method createPatternHelper.
public PatternHelper createPatternHelper(World worldIn, BlockPos p_181089_2_) {
Axis enumfacing$axis = Axis.Z;
Size blockportal$size = new Size(worldIn, p_181089_2_, Axis.X);
LoadingCache<BlockPos, BlockWorldState> loadingcache = BlockPattern.createLoadingCache(worldIn, true);
if (!blockportal$size.isValid()) {
enumfacing$axis = Axis.X;
blockportal$size = new Size(worldIn, p_181089_2_, Axis.Z);
}
if (!blockportal$size.isValid()) {
return new PatternHelper(p_181089_2_, EnumFacing.NORTH, EnumFacing.UP, loadingcache, 1, 1, 1);
}
int[] aint = new int[AxisDirection.values().length];
EnumFacing enumfacing = blockportal$size.rightDir.rotateYCCW();
BlockPos blockpos = blockportal$size.bottomLeft.up(blockportal$size.getHeight() - 1);
for (AxisDirection enumfacing$axisdirection : AxisDirection.values()) {
PatternHelper blockpattern$patternhelper = new PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
for (int i = 0; i < blockportal$size.getWidth(); ++i) {
for (int j = 0; j < blockportal$size.getHeight(); ++j) {
BlockWorldState blockworldstate = blockpattern$patternhelper.translateOffset(i, j, 1);
if (blockworldstate.getBlockState() != null && blockworldstate.getBlockState().getMaterial() != Material.AIR) {
++aint[enumfacing$axisdirection.ordinal()];
}
}
}
}
AxisDirection enumfacing$axisdirection1 = AxisDirection.POSITIVE;
for (AxisDirection enumfacing$axisdirection2 : AxisDirection.values()) {
if (aint[enumfacing$axisdirection2.ordinal()] < aint[enumfacing$axisdirection1.ordinal()]) {
enumfacing$axisdirection1 = enumfacing$axisdirection2;
}
}
return new PatternHelper(enumfacing.getAxisDirection() == enumfacing$axisdirection1 ? blockpos : blockpos.offset(blockportal$size.rightDir, blockportal$size.getWidth() - 1), EnumFacing.getFacingFromAxis(enumfacing$axisdirection1, enumfacing$axis), EnumFacing.UP, loadingcache, blockportal$size.getWidth(), blockportal$size.getHeight(), 1);
}
Aggregations