Skip to content

Commit

Permalink
fixed #74, added support for thrown Loyalty items.
Browse files Browse the repository at this point in the history
  • Loading branch information
blackd committed Dec 6, 2021
1 parent 7a9cbcc commit d926a9e
Show file tree
Hide file tree
Showing 18 changed files with 94 additions and 17 deletions.
7 changes: 7 additions & 0 deletions common/src/main/java/org/anti_ad/mc/ipnext/config/Configs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,20 @@ object AutoRefillSettings : ConfigDeclaration {
val DISABLE_FOR_DROP_ITEM /**/ by bool(false)
val REFILL_ARMOR /**/ by bool(true)
val REFILL_BEFORE_TOOL_BREAK /**/ by bool(true)
val DISABLE_FOR_LOYALTY_ITEMS /**/ by bool(true)
val TOOL_DAMAGE_THRESHOLD /**/ by int(10,
0,
100)
val THRESHOLD_UNIT /**/ by enum(ThresholdUnit.ABSOLUTE)
val AUTO_REFILL_WAIT_TICK /**/ by int(0,
0,
100)
.CATEGORY("$category.auto-refill.non-enchanted")
val ALLOW_BREAK_FOR_NON_ENCHANTED /**/ by bool(false)
val TOOL_MAX_DURABILITY_THRESHOLD /**/ by int(500,
0,
5000)

}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,28 @@
"inventoryprofiles.config.description.show_move_all_button": "Show \"Move All\" buttons in the container/player Gui.",
"inventoryprofiles.config.description.show_button_tooltips": "Display tooltips for the buttons.",

"inventoryprofiles.gui.config.AutoRefillSettings": "Auto Refill",
"inventoryprofiles.gui.config.AutoRefillSettings": "Auto Refill",

"inventoryprofiles.config.category.auto-refill.non-enchanted": "Non Enchanted Items",
"inventoryprofiles.config.name.disable_for_drop_item": "Disable For Dropped Item",
"inventoryprofiles.config.name.refill_armor": "Refill Armor Before It Breaks",
"inventoryprofiles.config.name.refill_before_tool_break": "Replace Tools Before They Break",
"inventoryprofiles.config.name.disable_for_loyalty_items": "Don't Replace Loyalty Gear",
"inventoryprofiles.config.name.tool_damage_threshold": "Damage Threshold",
"inventoryprofiles.config.name.threshold_unit": "Threshold Units",
"inventoryprofiles.config.name.auto_refill_wait_tick": "Number of Ticks to Wait Before Auto Refill",
"inventoryprofiles.config.name.allow_break_for_non_enchanted": "Allow Some Non Enchanted Gear to Break",
"inventoryprofiles.config.name.tool_max_durability_threshold": "Max Durability Threshold",
"inventoryprofiles.config.description.enable_auto_refill": "Refill the active item when the stack runs out.",
"inventoryprofiles.config.description.disable_for_drop_item": "Disable \"Auto Refill\" for dropped items",
"inventoryprofiles.config.description.refill_armor": "Refill armor slots if items are about to break",
"inventoryprofiles.config.description.refill_before_tool_break": "Refill tools and armor before they break.\nSee \"Damage Threshold\" for more information.",
"inventoryprofiles.config.description.disable_for_loyalty_items": "Disable replacement of Loyalty enchanted gear.\nWhen this is true anything that is enchanted with any level of Loyalty\n will not be replaced when thrown or dropped.",
"inventoryprofiles.config.description.tool_damage_threshold": "Controls the durability level that will trigger auto refill.",
"inventoryprofiles.config.description.threshold_unit": "Set the unit for \"Damage Threshold\".\nAbsolute value and percentage (%%) are supported.",
"inventoryprofiles.config.description.auto_refill_wait_tick": "Auto refill will wait this many ticks before doing the swap. \nThis might be useful on some during high server lag. \nHowever, depending on the \"Damage Threshold\" value, the tool might break before a swap is initiated.",
"inventoryprofiles.config.description.allow_break_for_non_enchanted": "Don't try to save non enchanted items.\nThat has maximum durability less than the setting below.",
"inventoryprofiles.config.description.tool_max_durability_threshold": "Tools with maximum durability below this value will be allowed to break if the setting above is true.\nThe idea that most players don't really want to keep stone tools,\n but will be annoyed if they break a dimond one.",



Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.common.vanilla.alias

import net.minecraft.command.arguments.NbtPathArgumentType
import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
Expand Down Expand Up @@ -52,6 +54,8 @@ typealias StringNbtReader = StringNbtReader // JsonToNBT.getTagFromJson = String
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.anti_ad.mc.ipnext.item


import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -98,6 +98,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCursed) -0.001 else level.toDouble() / enchantment.maximumLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.getEnchantments(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageable
inline val ItemType.maxDamage: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.common.vanilla.alias

import net.minecraft.command.argument.NbtPathArgumentType
import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
Expand Down Expand Up @@ -52,6 +54,8 @@ typealias StringNbtReader = StringNbtReader // JsonToNBT.getTagFromJson = String
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.anti_ad.mc.ipnext.item


import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -98,6 +98,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCursed) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.get(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageable
inline val ItemType.maxDamage: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.common.vanilla.alias

import net.minecraft.command.argument.NbtPathArgumentType
import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
Expand Down Expand Up @@ -53,6 +55,8 @@ typealias StringNbtReader = StringNbtReader // JsonToNBT.getTagFromJson = String
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.anti_ad.mc.ipnext.item

import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -96,6 +97,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCursed) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.get(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageable
inline val ItemType.maxDamage: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.common.vanilla.alias

import net.minecraft.command.argument.NbtPathArgumentType
import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.entity.effect.StatusEffectInstance
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
Expand Down Expand Up @@ -53,6 +55,8 @@ typealias StringNbtReader = StringNbtReader // JsonToNBT.getTagFromJson = String
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.anti_ad.mc.ipnext.item

import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -96,6 +97,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCursed) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.get(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageable
inline val ItemType.maxDamage: Int
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.common.vanilla.alias

import net.minecraft.command.arguments.NBTPathArgument
import net.minecraft.enchantment.Enchantment
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.enchantment.Enchantments
import net.minecraft.item.Item
import net.minecraft.item.ItemGroup
import net.minecraft.item.ItemStack
Expand Down Expand Up @@ -52,6 +54,8 @@ typealias StringNbtReader = JsonToNBT // JsonToNBT.getTagFromJson = StringNbtRea
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.anti_ad.mc.ipnext.item

import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -99,6 +100,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCurse) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.getEnchantments(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageable // .isDamageableItem
inline val ItemType.maxDamage: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.alchemy.PotionUtils
import net.minecraft.world.item.enchantment.Enchantment
import net.minecraft.world.item.enchantment.EnchantmentHelper
import net.minecraft.world.item.enchantment.Enchantments
import net.minecraft.nbt.Tag as NbtTag
import net.minecraft.tags.Tag as TagTag

Expand Down Expand Up @@ -52,6 +54,8 @@ typealias StringNbtReader = TagParser// JsonToNBT.getTagFromJson = StringNbtRea
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.anti_ad.mc.ipnext.item

import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -98,6 +99,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCurse) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.getEnchantments(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageableItem //isDamageable // .isDamageableItem
inline val ItemType.maxDamage: Int
Expand Down
2 changes: 1 addition & 1 deletion platforms/forge-1.18/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ val supported_minecraft_versions = listOf("1.18")
val mod_loader = "forge"
val mod_version = project.version
val minecraft_version = "1.18"
val forge_version = "38.0.14"
val forge_version = "38.0.15"
val mod_artefact_version = project.ext["mod_artefact_version"]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.alchemy.PotionUtils
import net.minecraft.world.item.enchantment.Enchantment
import net.minecraft.world.item.enchantment.EnchantmentHelper
import net.minecraft.world.item.enchantment.Enchantments
import net.minecraft.nbt.Tag as NbtTag
import net.minecraft.tags.Tag as TagTag

Expand Down Expand Up @@ -52,6 +54,8 @@ typealias StringNbtReader = TagParser// JsonToNBT.getTagFromJson = StringNbtRea
// ============

typealias EnchantmentHelper = EnchantmentHelper
typealias Enchantment = Enchantment
typealias Enchantments = Enchantments

// ============
// potion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.anti_ad.mc.ipnext.item

import net.minecraftforge.registries.ForgeRegistries
import org.anti_ad.mc.common.Log
import org.anti_ad.mc.common.extensions.ifTrue
import org.anti_ad.mc.common.vanilla.alias.Enchantment
import org.anti_ad.mc.common.vanilla.alias.EnchantmentHelper
import org.anti_ad.mc.common.vanilla.alias.Identifier
import org.anti_ad.mc.common.vanilla.alias.ItemGroup
Expand Down Expand Up @@ -98,6 +100,9 @@ inline val ItemType.enchantmentsScore: Double
acc + if (enchantment.isCurse) -0.001 else level.toDouble() / enchantment.maxLevel
} // cursed enchantments +0 scores

inline val ItemType.enchantments: MutableMap<Enchantment, Int>
get() = EnchantmentHelper.getEnchantments(vanillaStack)

inline val ItemType.isDamageable: Boolean
get() = vanillaStack.isDamageableItem //isDamageable // .isDamageableItem
inline val ItemType.maxDamage: Int
Expand Down Expand Up @@ -133,8 +138,9 @@ inline val ItemType.comparablePotionEffects: List<PotionEffect>
@Suppress("ObjectPropertyName")
inline val StatusEffectInstance.`(asComparable)`: PotionEffect
get() = PotionEffect(
Registry.MOB_EFFECT.getId(this.effect)
.toString(), // forge EFFECTS = STATUS_EFFECT == MOB_EFFECT | effectType = potion = effect
//this.effect.descriptionId
ForgeRegistries.MOB_EFFECTS.getKey(this.effect).toString(),
////Registry.MOB_EFFECT.getId(this.effect).toString(), // forge EFFECTS = STATUS_EFFECT == MOB_EFFECT | effectType = potion = effect
this.amplifier,
this.duration
)
Expand Down
Loading

0 comments on commit d926a9e

Please sign in to comment.