Skip to content

Commit

Permalink
fix: #23 - existing armor is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Duzos committed Aug 30, 2024
1 parent 0738688 commit 64ab0ec
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ private static void toCasePost(ServerPlayerEntity player, boolean force) {

public static boolean fromCase(ServerPlayerEntity player, boolean force) {
if (!force) {
if (!player.isOnGround()) return false;
if (!player.isOnGround()) return false; // not on ground
if (!player.getMainHandStack().isOf(Register.Items.MARK_FIVE_CASE)) return false; // not holding
if (getSet().isWearing(player)) return false; // already wearing
if (hasArmor(player)) return false; // wearing armor

player.getWorld().playSound(null, player.getBlockPos(), Register.Sounds.MARK5_NOISES, SoundCategory.PLAYERS, 0.25f, 1f);
Network.toTracking(new MarkFiveCaseS2CPacket(player.getUuid(), true), player);
Expand All @@ -72,6 +72,13 @@ public static boolean fromCase(ServerPlayerEntity player, boolean force) {
getSet().wear(player);
return true;
}
private static boolean hasArmor(ServerPlayerEntity player) {
for (ItemStack stack : player.getArmorItems()) {
if (!(stack.isEmpty())) return true;
}

return false;
}

private static SuitSet getSet() {
return SetRegistry.MARK_FIVE;
Expand Down

0 comments on commit 64ab0ec

Please sign in to comment.