-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3f1794
commit 3e2e3bc
Showing
12 changed files
with
771 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package at.hannibal2.skyhanni.api | ||
|
||
import at.hannibal2.skyhanni.data.jsonobjects.repo.neu.NeuReforgeJson | ||
import at.hannibal2.skyhanni.data.model.SkyblockStatList | ||
import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent | ||
import at.hannibal2.skyhanni.utils.ItemCategory | ||
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName | ||
import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull | ||
import at.hannibal2.skyhanni.utils.ItemUtils.itemNameWithoutColor | ||
import at.hannibal2.skyhanni.utils.LorenzRarity | ||
import at.hannibal2.skyhanni.utils.LorenzUtils | ||
import at.hannibal2.skyhanni.utils.NEUInternalName | ||
import net.minecraft.item.ItemStack | ||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent | ||
|
||
object ReforgeAPI { | ||
var reforgeList: List<Reforge> = emptyList() | ||
private set(value) { | ||
field = value | ||
nonePowerStoneReforge = value.filterNot { it.isReforgeStone } | ||
onlyPowerStoneReforge = value.filter { it.isReforgeStone } | ||
} | ||
|
||
var nonePowerStoneReforge: List<Reforge> = emptyList() | ||
private set | ||
|
||
var onlyPowerStoneReforge: List<Reforge> = emptyList() | ||
private set | ||
|
||
enum class ReforgeType { | ||
SWORD, BOW, ARMOR, CHESTPLATE, HELMET, CLOAK, AXE, HOE, AXE_AND_HOE, PICKAXE, EQUIPMENT, ROD, SWORD_AND_ROD, SPECIAL_ITEMS, VACUUM | ||
} | ||
|
||
class Reforge( | ||
val name: String, | ||
val type: ReforgeType, | ||
val stats: Map<LorenzRarity, SkyblockStatList>, | ||
val reforgeStone: NEUInternalName? = null, | ||
val specialItems: List<NEUInternalName>? = null, | ||
val extraProperty: Map<LorenzRarity, String> = emptyMap(), | ||
val costs: Map<LorenzRarity, Long>? = null | ||
) { | ||
|
||
val isReforgeStone = reforgeStone != null | ||
|
||
val rawReforgeStoneName = reforgeStone?.itemNameWithoutColor | ||
|
||
val lowercaseName = name.lowercase() | ||
|
||
fun isValid(itemStack: ItemStack) = isValid(itemStack.getItemCategoryOrNull(), itemStack.getInternalName()) | ||
|
||
fun isValid(itemCategory: ItemCategory?, internalName: NEUInternalName) = | ||
when (type) { | ||
ReforgeType.SWORD -> setOf( | ||
ItemCategory.SWORD, | ||
ItemCategory.GAUNTLET, | ||
ItemCategory.LONGSWORD, | ||
ItemCategory.FISHING_WEAPON | ||
).contains(itemCategory) | ||
|
||
ReforgeType.BOW -> itemCategory == ItemCategory.BOW || itemCategory == ItemCategory.SHORT_BOW | ||
ReforgeType.ARMOR -> setOf( | ||
ItemCategory.HELMET, | ||
ItemCategory.CHESTPLATE, | ||
ItemCategory.LEGGINGS, | ||
ItemCategory.BOOTS | ||
).contains(itemCategory) | ||
|
||
ReforgeType.CHESTPLATE -> itemCategory == ItemCategory.CHESTPLATE | ||
ReforgeType.HELMET -> itemCategory == ItemCategory.HELMET | ||
ReforgeType.CLOAK -> itemCategory == ItemCategory.CLOAK | ||
ReforgeType.AXE -> itemCategory == ItemCategory.AXE | ||
ReforgeType.HOE -> itemCategory == ItemCategory.HOE | ||
ReforgeType.AXE_AND_HOE -> itemCategory == ItemCategory.HOE || itemCategory == ItemCategory.AXE | ||
ReforgeType.PICKAXE -> itemCategory == ItemCategory.PICKAXE || itemCategory == ItemCategory.DRILL || itemCategory == ItemCategory.GAUNTLET | ||
ReforgeType.EQUIPMENT -> setOf( | ||
ItemCategory.CLOAK, | ||
ItemCategory.BELT, | ||
ItemCategory.NECKLACE, | ||
ItemCategory.BRACELET, | ||
ItemCategory.GLOVES | ||
).contains(itemCategory) | ||
|
||
ReforgeType.ROD -> itemCategory == ItemCategory.FISHING_ROD || itemCategory == ItemCategory.FISHING_WEAPON | ||
ReforgeType.SWORD_AND_ROD -> setOf( | ||
ItemCategory.SWORD, | ||
ItemCategory.GAUNTLET, | ||
ItemCategory.LONGSWORD, | ||
ItemCategory.FISHING_ROD, | ||
ItemCategory.FISHING_WEAPON | ||
).contains(itemCategory) | ||
|
||
ReforgeType.VACUUM -> itemCategory == ItemCategory.VACUUM | ||
ReforgeType.SPECIAL_ITEMS -> specialItems?.contains(internalName) ?: false | ||
} | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Reforge | ||
|
||
if (name != other.name) return false | ||
if (type != other.type) return false | ||
if (stats != other.stats) return false | ||
if (reforgeStone != other.reforgeStone) return false | ||
if (specialItems != other.specialItems) return false | ||
if (extraProperty != other.extraProperty) return false | ||
|
||
return true | ||
} | ||
|
||
override fun hashCode(): Int { | ||
var result = name.hashCode() | ||
result = 31 * result + type.hashCode() | ||
result = 31 * result + stats.hashCode() | ||
result = 31 * result + (reforgeStone?.hashCode() ?: 0) | ||
result = 31 * result + (specialItems?.hashCode() ?: 0) | ||
result = 31 * result + extraProperty.hashCode() | ||
return result | ||
} | ||
|
||
override fun toString(): String { | ||
return "Reforge $name" | ||
} | ||
|
||
} | ||
|
||
@SubscribeEvent | ||
fun onNeuRepoReload(event: NeuRepositoryReloadEvent) { | ||
val reforgeStoneData = event.readConstant<Map<String, NeuReforgeJson>>("reforgestones").values | ||
val reforgeData = event.readConstant<Map<String, NeuReforgeJson>>("reforges").values | ||
reforgeList = (reforgeStoneData + reforgeData).map(::mapReforge) | ||
} | ||
|
||
private fun mapReforge(it: NeuReforgeJson): Reforge { | ||
val type = it.itemType | ||
return Reforge( | ||
name = it.reforgeName, | ||
type = LorenzUtils.enumValueOf<ReforgeType>(type.first), | ||
stats = it.reforgeStats ?: emptyMap(), | ||
reforgeStone = it.internalName, | ||
specialItems = type.second.takeIf { it.isNotEmpty() }, | ||
extraProperty = it.reforgeAbility, | ||
costs = it.reforgeCosts | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...main/java/at/hannibal2/skyhanni/config/features/inventory/helper/ReforgeHelperConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package at.hannibal2.skyhanni.config.features.inventory.helper; | ||
|
||
import at.hannibal2.skyhanni.config.FeatureToggle; | ||
import at.hannibal2.skyhanni.config.core.config.Position; | ||
import com.google.gson.annotations.Expose; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; | ||
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; | ||
|
||
public class ReforgeHelperConfig { | ||
|
||
@Expose | ||
public Position posList = new Position(-200, 85, true, true); | ||
@Expose | ||
public Position posCurrent = new Position(280, 45, true, true); | ||
|
||
@Expose | ||
@ConfigOption(name = "Enable", desc = "Enables the reforge helper") | ||
@ConfigEditorBoolean | ||
@FeatureToggle | ||
public boolean enable = true; | ||
|
||
@Expose | ||
@ConfigOption(name = "Reforge Stones Hex Only", desc = "Displays reforge stones only when in Hex") | ||
@ConfigEditorBoolean | ||
public boolean reforgeStonesOnlyHex = true; | ||
|
||
@Expose | ||
@ConfigOption(name = "Hide chat", desc = "Hides the vanilla chat messages from reforging") | ||
@ConfigEditorBoolean | ||
public boolean hideChat = false; | ||
} |
Oops, something went wrong.