aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorLorenz <ESs95s3P5z8Pheb>2022-07-21 21:04:07 +0200
committerLorenz <ESs95s3P5z8Pheb>2022-07-21 21:04:07 +0200
commit972bdfb318d0ba2a2c483bc63eadb4225e5f528b (patch)
tree3ab91313637e7f49a502dbfe06a3c6e533a33567 /src/main/java
parent183c4cfaef952a229bc0abca297269dd8804498c (diff)
downloadskyhanni-972bdfb318d0ba2a2c483bc63eadb4225e5f528b.tar.gz
skyhanni-972bdfb318d0ba2a2c483bc63eadb4225e5f528b.tar.bz2
skyhanni-972bdfb318d0ba2a2c483bc63eadb4225e5f528b.zip
commit bunch of stuff needed more testig idk idc
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/RenderBlockInWorldEvent.kt9
-rw-r--r--src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt54
-rw-r--r--src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixinhooks/render/BlockRendererDispatcherHook.kt25
-rw-r--r--src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt8
8 files changed, 138 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderBlockInWorldEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderBlockInWorldEvent.kt
new file mode 100644
index 000000000..51e4ca411
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/RenderBlockInWorldEvent.kt
@@ -0,0 +1,9 @@
+//package at.hannibal2.skyhanni.events
+//
+//import net.minecraft.block.state.IBlockState
+//import net.minecraft.util.BlockPos
+//import net.minecraft.world.IBlockAccess
+//import net.minecraftforge.fml.common.eventhandler.Cancelable
+//
+//@Cancelable
+//data class RenderBlockInWorldEvent(@JvmField var state: IBlockState?, var world: IBlockAccess, var pos: BlockPos?) : LorenzEvent() \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt
index 1c2160009..4329a951c 100644
--- a/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt
+++ b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt
@@ -21,8 +21,8 @@ class TrophyFishMessages {
val trophyFishes = profileData["trophy_fish"].asJsonObject
for ((rawName, value) in trophyFishes.entrySet()) {
val rarity = when {
- rawName.endsWith("_silver") -> "silver"
rawName.endsWith("_bronze") -> "bronze"
+ rawName.endsWith("_silver") -> "silver"
rawName.endsWith("_gold") -> "gold"
rawName.endsWith("_diamond") -> "diamond"
else -> continue
diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt
index fe54c9405..97eefe1ab 100644
--- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.*
import at.hannibal2.skyhanni.utils.ItemUtils.cleanName
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.getSBItemID
import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes
import at.hannibal2.skyhanni.utils.RenderUtils.highlight
import com.google.gson.JsonObject
@@ -193,18 +194,20 @@ class HideNotClickableItems {
"CHESTPLATE",
"LEGGINGS",
"BOOTS",
+
"NECKLACE",
"CLOAK",
"BELT",
- "GLOVES"
+ "GLOVES",
+ "BRACELET"
)
for (type in list) {
- if (stack.getLore().any { it.contains("§l") && it.contains(type) }) {
+ if (stack.getLore().any { it.contains("§l") && it.contains(type) }) {//todo use item api
return false
}
}
- if (isSkyBlockMenuItem(stack.cleanName())) {
+ if (isSkyBlockMenuItem(stack)) {
hideReason = "The SkyBlock Menu cannot be put into the potion bag!"
return true
}
@@ -235,8 +238,7 @@ class HideNotClickableItems {
private fun hidePotionBag(chestName: String, stack: ItemStack): Boolean {
if (!chestName.startsWith("Potion Bag")) return false
- val name = stack.cleanName()
- if (isSkyBlockMenuItem(name)) {
+ if (isSkyBlockMenuItem(stack)) {
hideReason = "The SkyBlock Menu cannot be put into the potion bag!"
return true
}
@@ -250,8 +252,7 @@ class HideNotClickableItems {
private fun hideFishingBag(chestName: String, stack: ItemStack): Boolean {
if (!chestName.startsWith("Fishing Bag")) return false
- val name = stack.cleanName()
- if (isSkyBlockMenuItem(name)) {
+ if (isSkyBlockMenuItem(stack)) {
hideReason = "The SkyBlock Menu cannot be put into the fishing bag!"
return true
}
@@ -268,7 +269,7 @@ class HideNotClickableItems {
val name = stack.cleanName()
if (ItemUtils.isSack(name)) return false
- if (isSkyBlockMenuItem(name)) return false
+ if (isSkyBlockMenuItem(stack)) return false
hideReason = "This item is not a sack!"
return true
@@ -278,7 +279,7 @@ class HideNotClickableItems {
if (!chestName.startsWith("Accessory Bag")) return false
if (stack.getLore().any { it.contains("ACCESSORY") }) return false
- if (isSkyBlockMenuItem(stack.cleanName())) return false
+ if (isSkyBlockMenuItem(stack)) return false
hideReason = "This item is not an accessory!"
return true
@@ -292,6 +293,11 @@ class HideNotClickableItems {
return true
}
+ if (isSkyBlockMenuItem(stack)) {
+ hideReason = "The SkyBlock Menu cannot be traded!"
+ return true
+ }
+
val name = stack.cleanName()
if (ItemUtils.isSack(name)) {
@@ -299,11 +305,6 @@ class HideNotClickableItems {
return true
}
- if (isSkyBlockMenuItem(name)) {
- hideReason = "The SkyBlock Menu cannot be traded!"
- return true
- }
-
val result = hidePlayerTradeFilter.match(name)
LorenzDebug.log("hidePlayerTradeList filter result for '$name': $result")
@@ -321,7 +322,7 @@ class HideNotClickableItems {
name = name.substring(0, name.length - amountText.length)
}
- if (isSkyBlockMenuItem(name)) {
+ if (isSkyBlockMenuItem(stack)) {
hideReason = "The SkyBlock Menu cannot be sold at the NPC!"
return true
}
@@ -337,12 +338,13 @@ class HideNotClickableItems {
private fun hideInStorage(chestName: String, stack: ItemStack): Boolean {
if (!chestName.contains("Ender Chest") && !chestName.contains("Backpack") && chestName != "Storage") return false
- val name = stack.cleanName()
-
- if (isSkyBlockMenuItem(name)) {
+ if (isSkyBlockMenuItem(stack)) {
hideReason = "The SkyBlock Menu cannot be put into the storage!"
return true
}
+
+ val name = stack.cleanName()
+
if (ItemUtils.isSack(name)) {
hideReason = "Sacks cannot be put into the storage!"
return true
@@ -368,6 +370,11 @@ class HideNotClickableItems {
}
}
+ if (isSkyBlockMenuItem(stack)) {
+ hideReason = "The SkyBlock Menu cannot be salvaged!"
+ return true
+ }
+
val name = stack.cleanName()
for (item in itemsToSalvage) {
if (name.endsWith(item)) {
@@ -375,11 +382,6 @@ class HideNotClickableItems {
}
}
- if (isSkyBlockMenuItem(name)) {
- hideReason = "The SkyBlock Menu cannot be salvaged!"
- return true
- }
-
hideReason = "This item cannot be salvaged!"
return true
}
@@ -392,14 +394,14 @@ class HideNotClickableItems {
if (!bazaarInventory && !auctionHouseInventory) return false
- val displayName = stack.displayName
- if (isSkyBlockMenuItem(displayName.removeColorCodes())) {
+ if (isSkyBlockMenuItem(stack)) {
if (bazaarInventory) hideReason = "The SkyBlock Menu is not a Bazaar Product!"
if (auctionHouseInventory) hideReason = "The SkyBlock Menu cannot be auctioned!"
return true
}
+ val displayName = stack.displayName
if (bazaarInventory != BazaarApi.isBazaarItem(displayName)) {
if (bazaarInventory) hideReason = "This item is not a Bazaar Product!"
if (auctionHouseInventory) hideReason = "Bazaar Products cannot be auctioned!"
@@ -430,5 +432,5 @@ class HideNotClickableItems {
return result
}
- private fun isSkyBlockMenuItem(name: String): Boolean = name == "SkyBlock Menu (Click)"
+ private fun isSkyBlockMenuItem(stack: ItemStack): Boolean = stack.getSBItemID() == "SKYBLOCK_MENU"
}
diff --git a/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt
index d810aece5..d5054ae47 100644
--- a/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/items/ItemDisplayOverlayFeatures.kt
@@ -89,6 +89,8 @@ class ItemDisplayOverlayFeatures {
if (SkyHanniMod.feature.items.displaySackName) {
if (ItemUtils.isSack(name)) {
+ //TODO fix this and replace other
+// val sackName = grabSackName(name)
val split = name.split(" ")
val sackName = split[split.size - 2]
return (if (name.contains("Enchanted")) "§5" else "") + sackName.substring(0, 2)
@@ -107,4 +109,13 @@ class ItemDisplayOverlayFeatures {
return ""
}
+
+// private fun grabSackName(name: String): String {
+// val split = name.split(" ")
+// val text = split[0]
+// for (line in arrayOf("Large", "Medium", "Small", "Enchanted")) {
+// if (text == line) return grabSackName(name.substring(text.length + 1))
+// }
+// return text
+// }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/mixinhooks/render/BlockRendererDispatcherHook.kt b/src/main/java/at/hannibal2/skyhanni/mixinhooks/render/BlockRendererDispatcherHook.kt
new file mode 100644
index 000000000..d04e248ea
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixinhooks/render/BlockRendererDispatcherHook.kt
@@ -0,0 +1,25 @@
+//package at.hannibal2.skyhanni.mixinhooks.render
+//
+//import at.hannibal2.skyhanni.events.RenderBlockInWorldEvent
+//import net.minecraft.block.state.IBlockState
+//import net.minecraft.client.renderer.BlockRendererDispatcher
+//import net.minecraft.client.resources.model.IBakedModel
+//import net.minecraft.util.BlockPos
+//import net.minecraft.world.IBlockAccess
+//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
+//
+//fun modifyGetModelFromBlockState(
+// blockRendererDispatcher: Any,
+// state: IBlockState?,
+// worldIn: IBlockAccess,
+// pos: BlockPos?,
+// cir: CallbackInfoReturnable<IBakedModel>
+//) {
+// (blockRendererDispatcher as BlockRendererDispatcher).apply {
+// val event = RenderBlockInWorldEvent(state, worldIn, pos)
+// event.postAndCatch()
+// if (event.state !== state) {
+// cir.returnValue = blockModelShapes.getModelForState(event.state)
+// }
+// }
+//} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java
new file mode 100644
index 000000000..baec19192
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinBlockRendererDispatcher.java
@@ -0,0 +1,20 @@
+//package at.hannibal2.skyhanni.mixins.transformers.renderer;
+//
+//import net.minecraft.block.state.IBlockState;
+//import net.minecraft.client.renderer.BlockRendererDispatcher;
+//import net.minecraft.client.resources.IResourceManagerReloadListener;
+//import net.minecraft.client.resources.model.IBakedModel;
+//import net.minecraft.util.BlockPos;
+//import net.minecraft.world.IBlockAccess;
+//import org.spongepowered.asm.mixin.Mixin;
+//import org.spongepowered.asm.mixin.injection.At;
+//import org.spongepowered.asm.mixin.injection.Inject;
+//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+//
+//@Mixin(BlockRendererDispatcher.class)
+//public abstract class MixinBlockRendererDispatcher implements IResourceManagerReloadListener {
+// @Inject(method = "getModelFromBlockState", at = @At("RETURN"), cancellable = true)
+// private void modifyGetModelFromBlockState(IBlockState state, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<IBakedModel> cir) {
+//// BlockRendererDispatcherHookKt.modifyGetModelFromBlockState(this, state, worldIn, pos, cir);
+// }
+//}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
index ad6a29443..9b5e9621f 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt
@@ -2,8 +2,8 @@ package at.hannibal2.skyhanni.test
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.utils.GuiRender.renderString
-import at.hannibal2.skyhanni.utils.ItemUtil
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.ItemUtils.getSBItemID
import at.hannibal2.skyhanni.utils.LorenzDebug
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
@@ -28,7 +28,7 @@ class LorenzTest {
print("===")
print("ITEM LORE")
print("display name: '" + itemStack.displayName.toString() + "'")
- val itemID = ItemUtil.getSkyBlockItemID(itemStack)
+ val itemID = itemStack.getSBItemID()
print("itemID: '$itemID'")
// val rarity: ItemRarityOld = ItemUtils.getRarity(itemStack)
// print("rarity: '$rarity'")
@@ -101,4 +101,40 @@ class LorenzTest {
SkyHanniMod.feature.debug.testPos.renderString(text)
}
}
+
+// @SubscribeEvent
+// fun onGetBlockModel(event: RenderBlockInWorldEvent) {
+// if (!LorenzUtils.inSkyblock || !SkyHanniMod.feature.debug.enabled) return
+// val state = event.state
+//
+// if (event.state != null && event.pos != null) {
+//// if ((event.pos as BlockPos).y <= 76) {
+// val block = (state as IBlockState).block
+//
+//
+// if (block === Blocks.flowing_lava) {
+// event.state = Blocks.flowing_water.blockState.block.defaultState
+// }
+//
+// if (block === Blocks.lava) {
+// event.state = Blocks.water.blockState.block.defaultState
+// }
+//
+//
+//
+//// if (block === Blocks.redstone_lamp) {
+//// val blockState = Blocks.redstone_lamp.blockState
+//// event.state = blockState.block.defaultState
+//// }
+//// if (block === Blocks.flowing_lava &&
+//// (state as IBlockState).getValue(BlockStainedGlass.COLOR) == EnumDyeColor.WHITE
+//// ) {
+//// event.state = state.withProperty(BlockStainedGlass.COLOR, EnumDyeColor.GRAY)
+//// }
+//// if (block === Blocks.carpet && (state as IBlockState).getValue(BlockCarpet.COLOR) == EnumDyeColor.WHITE) {
+//// event.state = state.withProperty(BlockCarpet.COLOR, EnumDyeColor.GRAY)
+//// }
+//// }
+// }
+// }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
index 39eefff62..d97148242 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt
@@ -29,7 +29,7 @@ object ItemUtils {
return list
}
- fun isSack(name: String): Boolean = name.endsWith(" Sack")
+ fun isSack(name: String): Boolean = name.endsWith(" Sack")//TODO change
fun ItemStack.getLore() = ItemUtil.getItemLore(this)
@@ -41,7 +41,7 @@ object ItemUtils {
fun isSoulBound(stack: ItemStack): Boolean =
stack.getLore().any { it == "§8§l* §8Soulbound §8§l*" }
- fun isRecombobulated(stack: ItemStack): Boolean = stack.getLore().any { it.contains("§k") }
+ fun isRecombobulated(stack: ItemStack): Boolean = stack.getLore().any { it.contains("§k") }//TODO use item api
fun isPet(name: String): Boolean = name.matchRegex("\\[Lvl (.*)] (.*)") && !listOf(
"Archer",
@@ -94,4 +94,8 @@ object ItemUtils {
}
return false
}
+
+ fun ItemStack.getSBItemID(): String {
+ return ItemUtil.getSkyBlockItemID(this) ?: ""
+ }
} \ No newline at end of file