Skip to content

Commit 3ba8a68

Browse files
Fixes in quick armor swap
1 parent 18fa8a3 commit 3ba8a68

File tree

1 file changed

+14
-12
lines changed
  • src/main/java/me/juancarloscp52/bedrockify/client/features/quickArmorSwap

1 file changed

+14
-12
lines changed

src/main/java/me/juancarloscp52/bedrockify/client/features/quickArmorSwap/ArmorReplacer.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@ public class ArmorReplacer {
1717

1818
public static TypedActionResult<ItemStack> tryChangeArmor(PlayerEntity playerEntity, Hand hand){
1919
ItemStack newArmor = playerEntity.getStackInHand(hand);
20-
if (newArmor.getItem() == Items.ELYTRA || newArmor.getItem() instanceof ArmorItem){
21-
ClientPlayerInteractionManager interactionManager = MinecraftClient.getInstance().interactionManager;
22-
if(interactionManager != null && MinecraftClient.getInstance().mouse.wasRightButtonClicked()){
23-
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(newArmor);
20+
ClientPlayerInteractionManager interactionManager = MinecraftClient.getInstance().interactionManager;
21+
if(interactionManager != null && MinecraftClient.getInstance().mouse.wasRightButtonClicked()){
22+
if (!(newArmor.getItem() == Items.ELYTRA || newArmor.getItem() instanceof ArmorItem))
23+
return TypedActionResult.pass(newArmor);
2424

25-
if(!playerEntity.getEquippedStack(equipmentSlot).getItem().equals(Items.AIR)){
26-
int slotIndex = 8-equipmentSlot.getEntitySlotId();
27-
interactionManager.clickSlot(playerEntity.playerScreenHandler.syncId,slotIndex,playerEntity.inventory.main.indexOf(newArmor), SlotActionType.SWAP,playerEntity);
28-
playerEntity.playSound(newArmor.getItem() == Items.ELYTRA ? SoundEvents.ITEM_ARMOR_EQUIP_ELYTRA : ((ArmorItem)newArmor.getItem()).getMaterial().getEquipSound(), 1.0F,1.0F);
29-
return TypedActionResult.success(playerEntity.getStackInHand(hand));
30-
}
31-
}
25+
EquipmentSlot equipmentSlot = MobEntity.getPreferredEquipmentSlot(newArmor);
26+
27+
if(playerEntity.getEquippedStack(equipmentSlot).getItem().equals(Items.AIR))
28+
return TypedActionResult.pass(newArmor);
29+
30+
int slotIndex = 8-equipmentSlot.getEntitySlotId();
31+
interactionManager.clickSlot(playerEntity.playerScreenHandler.syncId,slotIndex,playerEntity.inventory.main.indexOf(newArmor), SlotActionType.SWAP,playerEntity);
32+
playerEntity.playSound(newArmor.getItem() == Items.ELYTRA ? SoundEvents.ITEM_ARMOR_EQUIP_ELYTRA : ((ArmorItem)newArmor.getItem()).getMaterial().getEquipSound(), 1.0F,1.0F);
33+
return TypedActionResult.success(playerEntity.getStackInHand(hand));
3234
}
33-
return TypedActionResult.pass(newArmor);
35+
return TypedActionResult.fail(newArmor);
3436
}
3537

3638
}

0 commit comments

Comments
 (0)