Skip to content

Commit

Permalink
fixed restricting #774
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke100000 committed Oct 31, 2023
1 parent 527a5ac commit 9670091
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Added support for Let's Do Bakery
* Fixed root advancement to appear on world load
* Fixed villager marriage limit math
* You can no longer restrict bells or gravestones, causing them to get stuck

# 7.5.9

Expand Down
25 changes: 14 additions & 11 deletions common/src/main/java/net/mca/network/c2s/ReportBuildingMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,26 @@ public void receive(ServerPlayerEntity player) {
);
case FORCE_TYPE, REMOVE -> {
Optional<Village> village = villages.findNearestVillage(player);
Optional<Building> building = village.flatMap(v -> v.getBuildings().values().stream().filter((b) ->
b.containsPos(player.getBlockPos())).findAny());
if (building.isPresent()) {
Optional<Building> building = village.flatMap(v -> v.getBuildings().values().stream()
.filter(b -> b.containsPos(player.getBlockPos()))
.filter(b -> action != Action.FORCE_TYPE || !b.getBuildingType().grouped())
.findAny());
building.ifPresentOrElse(b -> {
if (action == Action.FORCE_TYPE) {
if (building.get().getType().equals(data)) {
building.get().setTypeForced(false);
building.get().determineType();
if (b.getType().equals(data)) {
b.setTypeForced(false);
b.determineType();
} else {
building.get().setTypeForced(true);
building.get().setType(data);
b.setTypeForced(true);
b.setType(data);
}
} else {
village.get().removeBuilding(building.get().getId());
//noinspection OptionalGetWithoutIsPresent
village.get().removeBuilding(b.getId());
}
} else {
}, () -> {
player.sendMessage(Text.translatable("blueprint.noBuilding"), true);
}
});
}
}
}
Expand Down

0 comments on commit 9670091

Please sign in to comment.