diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt index e97fae849..a79ab1ead 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/item/tool/ExplosiveHammerItem.kt @@ -63,7 +63,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) } fun canPrime(player: Player): Boolean { - return player.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 && + return player.hasInfiniteMaterials() || player.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 && player.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 0, player.inventoryMenu.craftSlots) > 0 } @@ -142,7 +142,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) } fun attackAt(itemStack: ItemStack, attacker: LivingEntity, pos: Vec3, aim: Vec3, hand: InteractionHand) { - if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && attacker.getAttackStrengthScale(0.4f) < 0.98f) + if (!isPrimed(itemStack) || attacker.level().isClientSide || attacker is Player && !attacker.isCreative && attacker.getAttackStrengthScale(0.4f) < 0.98f) return val (ex, ey, ez) = pos @@ -221,7 +221,7 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) it.connection.send(ClientboundExplodePacket(ex, ey, ez, 1f, exp.toBlow, exp.hitPlayers[it], Explosion.BlockInteraction.DESTROY, ParticleTypes.EXPLOSION, ParticleTypes.EXPLOSION_EMITTER, SoundEvents.GENERIC_EXPLODE)) } - if (attacker !is Player || !attacker.isCreative) { + if (!attacker.hasInfiniteMaterials()) { unprime(itemStack) val copy = itemStack.copy() @@ -303,8 +303,10 @@ class ExplosiveHammerItem(durability: Int = 512) : Item(Properties().stacksTo(1) override fun finishUsingItem(stack: ItemStack, level: Level, entity: LivingEntity): ItemStack { if (entity is Player && canPrime(entity)) { if (level is ServerLevel) { - entity.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 1, entity.inventoryMenu.craftSlots) - entity.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 1, entity.inventoryMenu.craftSlots) + if (!entity.hasInfiniteMaterials()) { + entity.inventory.clearOrCountMatchingItems(GUNPOWDER_PREDICATE, 1, entity.inventoryMenu.craftSlots) + entity.inventory.clearOrCountMatchingItems(IRON_NUGGET_PREDICATE, 1, entity.inventoryMenu.craftSlots) + } prime(stack) }