Skip to content

Commit

Permalink
Hacky fix for carry on firing a forge event at the wrong time
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Feb 11, 2023
1 parent 1922647 commit f72328f
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,18 @@ public static InteractionResult onChestplateUse(Player player, ItemStack chestpl
/** Handles attacking using the chestplate */
@SubscribeEvent(priority = EventPriority.LOW)
static void onChestplateAttack(AttackEntityEvent event) {
Player attacker = event.getPlayer();
if (attacker.getMainHandItem().isEmpty()) {
ItemStack chestplate = attacker.getItemBySlot(EquipmentSlot.CHEST);
if (chestplate.is(TinkerTags.Items.UNARMED)) {
ToolStack tool = ToolStack.from(chestplate);
if (!tool.isBroken()) {
ToolAttackUtil.attackEntity(tool, attacker, InteractionHand.MAIN_HAND, event.getTarget(), ToolAttackUtil.getCooldownFunction(attacker, InteractionHand.MAIN_HAND), false, EquipmentSlot.CHEST);
event.setCanceled(true);
// Carry On is dumb and fires the attack entity event when they are not attacking entities, causing us to punch instead
// they should not be doing that, but the author has not done anything to fix it, so just use a hacky check
if (event.getClass() == AttackEntityEvent.class) {
Player attacker = event.getPlayer();
if (attacker.getMainHandItem().isEmpty()) {
ItemStack chestplate = attacker.getItemBySlot(EquipmentSlot.CHEST);
if (chestplate.is(TinkerTags.Items.UNARMED)) {
ToolStack tool = ToolStack.from(chestplate);
if (!tool.isBroken()) {
ToolAttackUtil.attackEntity(tool, attacker, InteractionHand.MAIN_HAND, event.getTarget(), ToolAttackUtil.getCooldownFunction(attacker, InteractionHand.MAIN_HAND), false, EquipmentSlot.CHEST);
event.setCanceled(true);
}
}
}
}
Expand Down

0 comments on commit f72328f

Please sign in to comment.