Skip to content

Commit

Permalink
Extract ball loot fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
Waterpicker committed Dec 5, 2024
1 parent 1b75f8e commit 83b1aca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ protected BallLootBlock(String name, PokeBall ball) {
var list = be.isCustomDrop() ? be.getCustomDrops() : getDrops((ServerLevel) level, pos, player);
Containers.dropContents(level, pos.above(), list);

be.removeClaimer(playerUUID);
be.addClaimer(playerUUID);
level.playSound(null, player.getX(), player.getY(), player.getZ(), GenerationsSounds.LUGIA_SHRINE_SONG.get(), SoundSource.BLOCKS, 0.2f, 1.0f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,14 @@ public boolean canClaim(UUID playerUUID) {
if (!this.lootMode.isDropOnce()) return true;

Optional<LootClaim> claim = this.getLootClaim(playerUUID);
return claim.isEmpty() || this.lootMode.isTimeEnabled() && Instant.now().plus(GenerationsCore.CONFIG.lootTime).isAfter(claim.get().time());

if (claim.isEmpty()) return true;
if (this.lootMode.isTimeEnabled())
if (Instant.now().plus(GenerationsCore.CONFIG.lootTime).isAfter(claim.get().time())) {
removeClaimer(playerUUID);
return true;
}
return false;
}

public void addClaimer(UUID playerUUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
import java.util.UUID;

public record LootClaim(UUID uuid, Instant time) {
public boolean isExpired() {
return Instant.now().isAfter(time);
}
}

0 comments on commit 83b1aca

Please sign in to comment.