Skip to content

Commit

Permalink
let mother boss bar track the vulnerability health
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 11, 2023
1 parent 9fd3a2d commit 46481a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ public void onVulnerabilityHit(LivingEntity entity, boolean destroyed) {

public void updateFightStatus() {
List<Triple<BlockPos, BlockState, IRemainsBlock>> vuls = getTreeStructure(false).getVerifiedVulnerabilities(level).toList();
long remainingVulnerabilities = vuls.stream().filter(vul -> vul.getRight().isVulnerable(vul.getMiddle())).count();
int remainingVulnerabilities = vuls.stream().filter(vul -> vul.getRight().isVulnerable(vul.getMiddle())).map(s -> level.getBlockEntity(s.getLeft())).filter(VulnerableRemainsBlockEntity.class::isInstance).map(VulnerableRemainsBlockEntity.class::cast).mapToInt(VulnerableRemainsBlockEntity::getHealth).sum();
if (remainingVulnerabilities > 0) {
this.bossEvent.setProgress(remainingVulnerabilities / (float) vuls.size());
this.bossEvent.setProgress(remainingVulnerabilities / ((float) vuls.size() * VulnerableRemainsBlockEntity.MAX_HEALTH));
} else {
this.bossEvent.setProgress(0);
this.endFight();
Expand All @@ -209,7 +209,7 @@ private void endFight() {

private void freezeFight() {
this.isFrozen = true;
this.freezeTimer = 20 * 10;
this.freezeTimer = 20 * 20;
getTreeStructure(false).getVerifiedVulnerabilities(this.level).forEach(vul -> vul.getRight().freeze(level, vul.getLeft(), vul.getMiddle()));
this.bossEvent.setColor(BossEvent.BossBarColor.WHITE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class VulnerableRemainsBlockEntity extends BlockEntity {

private final static int MAX_HEALTH = 100;
public final static int MAX_HEALTH = 100;

public static void serverTick(ServerLevel level, BlockPos blockPos, BlockState blockState, VulnerableRemainsBlockEntity e) {
if (e.firstTick) {
Expand Down

0 comments on commit 46481a8

Please sign in to comment.