aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorThunderblade73 <85900443+Thunderblade73@users.noreply.github.com>2024-02-10 21:25:20 +0100
committerGitHub <noreply@github.com>2024-02-10 21:25:20 +0100
commit3ced2632ac23d968601f83374b8b3ceee0fc5e36 (patch)
tree009a29156bcf4a3c8b6e604d9a33360aa1a13eb5 /src/main/java/at
parentffbb693db7921a2d145c545833a98248e4623bf4 (diff)
downloadskyhanni-3ced2632ac23d968601f83374b8b3ceee0fc5e36.tar.gz
skyhanni-3ced2632ac23d968601f83374b8b3ceee0fc5e36.tar.bz2
skyhanni-3ced2632ac23d968601f83374b8b3ceee0fc5e36.zip
Blocks the mining ability when on private island. #860
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt30
8 files changed, 63 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index c885101dc..401b8c020 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -263,6 +263,7 @@ import at.hannibal2.skyhanni.features.misc.PetExpTooltip
import at.hannibal2.skyhanni.features.misc.PetItemDisplay
import at.hannibal2.skyhanni.features.misc.PlayerChatSymbols
import at.hannibal2.skyhanni.features.misc.PocketSackInASackDisplay
+import at.hannibal2.skyhanni.features.misc.PrivateIslandNoPickaxeAbility
import at.hannibal2.skyhanni.features.misc.QuickModMenuSwitch
import at.hannibal2.skyhanni.features.misc.RestorePieceOfWizardPortalLore
import at.hannibal2.skyhanni.features.misc.ServerRestartTitle
@@ -592,6 +593,7 @@ class SkyHanniMod {
loadModule(GardenLevelDisplay())
loadModule(FarmingWeightDisplay())
loadModule(DicerRngDropTracker)
+ loadModule(PrivateIslandNoPickaxeAbility())
loadModule(CropMoneyDisplay)
loadModule(JacobFarmingContestsInventory())
loadModule(GardenNextJacobContest)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
index 9b385494b..963b04825 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java
@@ -39,4 +39,10 @@ public class MiningConfig {
@ConfigEditorBoolean
@FeatureToggle
public boolean crystalHollowsNamesInCore = false;
+
+ @Expose
+ @ConfigOption(name = "Private Island Ability Block", desc = "Blocks the mining ability when on private island")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean privateIslandNoPickaxeAbility = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
index 4aa796b54..9a7742a29 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ItemClickData.kt
@@ -22,18 +22,18 @@ class ItemClickData {
if (packet is C08PacketPlayerBlockPlacement) {
if (packet.placedBlockDirection != 255) {
val position = packet.position.toLorenzVec()
- BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch()
+ event.isCanceled = BlockClickEvent(ClickType.RIGHT_CLICK, position, packet.stack).postAndCatch()
} else {
- ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).postAndCatch()
+ event.isCanceled = ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.RIGHT_CLICK).postAndCatch()
}
}
if (packet is C07PacketPlayerDigging && packet.status == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) {
val position = packet.position.toLorenzVec()
- BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).postAndCatch()
- ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).postAndCatch()
+ val blockClickCancelled = BlockClickEvent(ClickType.LEFT_CLICK, position, InventoryUtils.getItemInHand()).postAndCatch()
+ event.isCanceled = ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).also { it.isCanceled = blockClickCancelled }.postAndCatch()
}
if (packet is C0APacketAnimation) {
- ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).postAndCatch()
+ event.isCanceled = ItemClickEvent(InventoryUtils.getItemInHand(), ClickType.LEFT_CLICK).postAndCatch()
}
}
@@ -56,6 +56,6 @@ class ItemClickData {
if (minecraft.thePlayer == null) return
if (clickedEntity == null) return
- EntityClickEvent(clickType, clickedEntity).postAndCatch()
+ event.isCanceled = EntityClickEvent(clickType, clickedEntity, InventoryUtils.getItemInHand()).postAndCatch()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
index 0ca9fb78c..2822c28a9 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt
@@ -4,8 +4,11 @@ import at.hannibal2.skyhanni.data.ClickType
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockStateAt
import at.hannibal2.skyhanni.utils.LorenzVec
import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.Cancelable
-class BlockClickEvent(val clickType: ClickType, val position: LorenzVec, val itemInHand: ItemStack?) : LorenzEvent() {
+@Cancelable
+class BlockClickEvent(clickType: ClickType, val position: LorenzVec, itemInHand: ItemStack?) :
+ WorldClickEvent(itemInHand, clickType) {
val getBlockState by lazy { position.getBlockStateAt() }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt
index d5d7fe573..ec9785fce 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/EntityClickEvent.kt
@@ -2,5 +2,8 @@ package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.data.ClickType
import net.minecraft.entity.Entity
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.Cancelable
-class EntityClickEvent(val clickType: ClickType, val clickedEntity: Entity?) : LorenzEvent() \ No newline at end of file
+@Cancelable
+class EntityClickEvent(clickType: ClickType, val clickedEntity: Entity?, itemInHand: ItemStack?) : WorldClickEvent(itemInHand, clickType)
diff --git a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt
index 5bf89558a..a34cb43f1 100644
--- a/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt
+++ b/src/main/java/at/hannibal2/skyhanni/events/ItemClickEvent.kt
@@ -2,5 +2,7 @@ package at.hannibal2.skyhanni.events
import at.hannibal2.skyhanni.data.ClickType
import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.Cancelable
-class ItemClickEvent(val itemInHand: ItemStack?, val clickType: ClickType) : LorenzEvent()
+@Cancelable
+class ItemClickEvent(itemInHand: ItemStack?, clickType: ClickType) : WorldClickEvent(itemInHand, clickType)
diff --git a/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt
new file mode 100644
index 000000000..4597041a1
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/events/WorldClickEvent.kt
@@ -0,0 +1,8 @@
+package at.hannibal2.skyhanni.events
+
+import at.hannibal2.skyhanni.data.ClickType
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.Cancelable
+
+@Cancelable
+open class WorldClickEvent(val itemInHand: ItemStack?, val clickType: ClickType) : LorenzEvent()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt
new file mode 100644
index 000000000..65559d8a6
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/PrivateIslandNoPickaxeAbility.kt
@@ -0,0 +1,30 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ClickType
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.events.WorldClickEvent
+import at.hannibal2.skyhanni.utils.ItemCategory
+import at.hannibal2.skyhanni.utils.ItemUtils.getItemCategoryOrNull
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class PrivateIslandNoPickaxeAbility {
+
+ val config get() = SkyHanniMod.feature.mining
+
+ @SubscribeEvent
+ fun onClick(event: WorldClickEvent) {
+ if (!IslandType.PRIVATE_ISLAND.isInIsland()) return
+ if (!config.privateIslandNoPickaxeAbility) return
+ if (event.clickType != ClickType.RIGHT_CLICK) return
+
+ when (event.itemInHand?.getItemCategoryOrNull()) {
+ ItemCategory.GAUNTLET, ItemCategory.PICKAXE, ItemCategory.DRILL -> {
+ event.isCanceled = true
+ }
+
+ else -> {}
+ }
+ }
+}