Skip to content

Commit

Permalink
Changed the way the health for buildings is calculated to calculate m…
Browse files Browse the repository at this point in the history
…ore accurate value.
  • Loading branch information
remmintan committed Dec 3, 2024
1 parent 5575a6c commit 62516bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ private static boolean shouldSkipState(BlockState state) {
}

private static boolean shouldSkipBlock(BlockPos pos, BlockState state, int floorYLevel) {

if (state.isAir() || !state.getFluidState().isEmpty() || state.getBlock() == Blocks.STRUCTURE_VOID)
return true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ class FortressBuildingBlockEntity(pos: BlockPos?, state: BlockState?) :
this.blueprintMetadata = metadata
this.start = start
this.end = end
this.blockData = FortressBuildingBlockData(blockData, metadata.floorLevel)

val movedBlocksData = blockData.mapKeys { it.key.add(start) }

this.blockData = FortressBuildingBlockData(movedBlocksData, metadata.floorLevel)
this.automationArea = BuildingAutomationAreaProvider(start, end, metadata.requirement)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ public FortressBuildingManager(Supplier<ServerWorld> worldSupplier, IServerFortr
return buildingPos;
}

public void addBuilding(BlueprintMetadata metadata, BlockPos start, BlockPos end, Map<BlockPos, BlockState> mergedBlockData) {
public void addBuilding(BlueprintMetadata metadata, BlockPos start, BlockPos end, Map<BlockPos, BlockState> blockData) {
final var blockBox = BlockBox.create(start, end);
final var buildingPos = getCenterTop(blockBox);

final var world = getWorld();
world.setBlockState(buildingPos, FortressBlocks.FORTRESS_BUILDING.getDefaultState(), 3);
final var blockEntity = world.getBlockEntity(buildingPos);
if (blockEntity instanceof FortressBuildingBlockEntity b) {
b.init(metadata, start, end, mergedBlockData);
b.init(metadata, start, end, blockData);
}

fortressManager.expandTheVillage(start);
Expand Down

0 comments on commit 62516bd

Please sign in to comment.