use of mekanism.generators.common.tile.fission.TileEntityFissionFuelAssembly in project Mekanism by mekanism.
the class FissionReactorValidator method postcheck.
@Override
public FormationResult postcheck(FissionReactorMultiblockData structure, Set<BlockPos> innerNodes, Long2ObjectMap<IChunk> chunkMap) {
Map<AssemblyPos, FuelAssembly> map = new HashMap<>();
Set<BlockPos> fuelAssemblyCoords = new HashSet<>();
int assemblyCount = 0, surfaceArea = 0;
for (BlockPos coord : innerNodes) {
TileEntity tile = WorldUtils.getTileEntity(world, chunkMap, coord);
AssemblyPos pos = new AssemblyPos(coord.getX(), coord.getZ());
FuelAssembly assembly = map.get(pos);
if (tile instanceof TileEntityFissionFuelAssembly) {
if (assembly == null) {
map.put(pos, new FuelAssembly(coord, false));
} else {
assembly.fuelAssemblies.add(coord);
}
assemblyCount++;
// compute surface area
surfaceArea += 6;
for (Direction side : EnumUtils.DIRECTIONS) {
if (fuelAssemblyCoords.contains(coord.relative(side))) {
surfaceArea -= 2;
}
}
fuelAssemblyCoords.add(coord);
structure.internalLocations.add(coord);
} else if (tile instanceof TileEntityControlRodAssembly) {
if (assembly == null) {
map.put(pos, new FuelAssembly(coord, true));
} else if (assembly.controlRodAssembly != null) {
// only one control rod per assembly
return FormationResult.fail(GeneratorsLang.FISSION_INVALID_EXTRA_CONTROL_ROD, coord);
} else {
assembly.controlRodAssembly = coord;
}
}
}
// require at least one fuel assembly
if (map.isEmpty()) {
return FormationResult.fail(GeneratorsLang.FISSION_INVALID_MISSING_FUEL_ASSEMBLY);
}
for (Entry<AssemblyPos, FuelAssembly> entry : map.entrySet()) {
FuelAssembly assembly = entry.getValue();
FormationResult result = assembly.validate(entry.getKey());
if (!result.isFormed()) {
return result;
}
structure.assemblies.add(assembly.build());
}
structure.fuelAssemblies = assemblyCount;
structure.surfaceArea = surfaceArea;
return FormationResult.SUCCESS;
}
Aggregations