diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/events')
23 files changed, 52 insertions, 36 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt index b256113a3..0ca9fb78c 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/BlockClickEvent.kt @@ -6,5 +6,6 @@ import at.hannibal2.skyhanni.utils.LorenzVec import net.minecraft.item.ItemStack class BlockClickEvent(val clickType: ClickType, val position: LorenzVec, val itemInHand: ItemStack?) : LorenzEvent() { + val getBlockState by lazy { position.getBlockStateAt() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt index bd9a816cb..13da59c43 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/CheckRenderEntityEvent.kt @@ -10,5 +10,5 @@ data class CheckRenderEntityEvent<T : Entity>( val camera: ICamera, val camX: Double, val camY: Double, - val camZ: Double -) : LorenzEvent()
\ No newline at end of file + val camZ: Double, +) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt index 469dee006..1bc664cda 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/CropClickEvent.kt @@ -9,5 +9,5 @@ class CropClickEvent( val crop: CropType, val blockState: IBlockState, val clickType: ClickType, - val itemInHand: ItemStack? -) : LorenzEvent()
\ No newline at end of file + val itemInHand: ItemStack?, +) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt index eecc132ca..efef20840 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityEquipmentChangeEvent.kt @@ -6,8 +6,9 @@ import net.minecraft.item.ItemStack data class EntityEquipmentChangeEvent( val entity: Entity, val equipmentSlot: Int, - val newItemStack: ItemStack? + val newItemStack: ItemStack?, ) : LorenzEvent() { + val isHead get() = equipmentSlot == EQUIPMENT_SLOT_HEAD val isChest get() = equipmentSlot == EQUIPMENT_SLOT_CHEST val isLeggings get() = equipmentSlot == EQUIPMENT_SLOT_LEGGINGS @@ -15,6 +16,7 @@ data class EntityEquipmentChangeEvent( val isHand get() = equipmentSlot == EQUIPMENT_SLOT_HAND companion object { + const val EQUIPMENT_SLOT_HEAD = 4 const val EQUIPMENT_SLOT_CHEST = 3 const val EQUIPMENT_SLOT_LEGGINGS = 2 diff --git a/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt index b09062543..68c913c1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/EntityMoveEvent.kt @@ -7,5 +7,5 @@ class EntityMoveEvent( val entity: Entity, val oldLocation: LorenzVec, val newLocation: LorenzVec, - val distance: Double -) : LorenzEvent()
\ No newline at end of file + val distance: Double, +) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt index 437130bdd..f6ffc4295 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiContainerEvent.kt @@ -12,7 +12,7 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: override val container: Container, val mouseX: Int, val mouseY: Int, - val partialTicks: Float + val partialTicks: Float, ) : GuiContainerEvent(gui, container) @Cancelable @@ -21,18 +21,19 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: abstract class DrawSlotEvent(gui: GuiContainer, container: Container, open val slot: Slot) : GuiContainerEvent(gui, container) { + @Cancelable data class GuiContainerDrawSlotPre( override val gui: GuiContainer, override val container: Container, - override val slot: Slot + override val slot: Slot, ) : DrawSlotEvent(gui, container, slot) data class GuiContainerDrawSlotPost( override val gui: GuiContainer, override val container: Container, - override val slot: Slot + override val slot: Slot, ) : DrawSlotEvent(gui, container, slot) } @@ -42,7 +43,7 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: override val container: Container, val mouseX: Int, val mouseY: Int, - val partialTicks: Float + val partialTicks: Float, ) : GuiContainerEvent(gui, container) @Cancelable @@ -52,6 +53,6 @@ abstract class GuiContainerEvent(open val gui: GuiContainer, open val container: val slot: Slot?, val slotId: Int, val clickedButton: Int, - val clickType: Int + val clickType: Int, ) : GuiContainerEvent(gui, container) -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/GuiRenderItemEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderItemEvent.kt index f879dbc39..58dc557e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/GuiRenderItemEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/GuiRenderItemEvent.kt @@ -9,15 +9,16 @@ abstract class GuiRenderItemEvent : LorenzEvent() { open val stack: ItemStack?, open val x: Int, open val y: Int, - open val text: String? + open val text: String?, ) : GuiRenderItemEvent() { + data class GuiRenderItemPost( override val fontRenderer: FontRenderer, override val stack: ItemStack?, override val x: Int, override val y: Int, - override val text: String? + override val text: String?, ) : RenderOverlayEvent(fontRenderer, stack, x, y, text) } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/InventoryCloseEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/InventoryCloseEvent.kt index 72630756a..7b94efd55 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/InventoryCloseEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/InventoryCloseEvent.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.OtherInventoryData import net.minecraft.item.ItemStack class InventoryCloseEvent(val inventory: OtherInventoryData.Inventory, val reopenSameName: Boolean) : LorenzEvent() { + val inventoryId: Int by lazy { inventory.windowId } val inventoryName: String by lazy { inventory.title } val inventorySize: Int by lazy { inventory.slotCount } diff --git a/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt index 7ff2ca293..bc9e97ed8 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/InventoryFullyOpenedEvent.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.OtherInventoryData import net.minecraft.item.ItemStack open class InventoryOpenEvent(private val inventory: OtherInventoryData.Inventory) : LorenzEvent() { + val inventoryId: Int by lazy { inventory.windowId } val inventoryName: String by lazy { inventory.title } val inventorySize: Int by lazy { inventory.slotCount } diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzChatEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzChatEvent.kt index acce544db..c2c51cec6 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzChatEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzChatEvent.kt @@ -6,5 +6,5 @@ class LorenzChatEvent( var message: String, var chatComponent: IChatComponent, var blockedReason: String = "", - var chatLineId: Int = 0 + var chatLineId: Int = 0, ) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt index 90d68ed35..c83ec95aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzEvent.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.mixins.hooks.getValue import at.hannibal2.skyhanni.mixins.hooks.setValue import at.hannibal2.skyhanni.mixins.transformers.AccessorEventBus import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.ChatUtils import net.minecraftforge.common.MinecraftForge import net.minecraftforge.fml.common.eventhandler.Event import net.minecraftforge.fml.common.eventhandler.IEventListener @@ -19,6 +19,7 @@ abstract class LorenzEvent : Event() { fun postAndCatch() = postAndCatchAndBlock {} companion object { + var eventHandlerDepth by object : ThreadLocal<Int>() { override fun initialValue(): Int { return 0 @@ -55,7 +56,7 @@ abstract class LorenzEvent : Event() { eventHandlerDepth-- if (errors > visibleErrors) { val hiddenErrors = errors - visibleErrors - LorenzUtils.error("$hiddenErrors more errors in $eventName are hidden!") + ChatUtils.error("$hiddenErrors more errors in $eventName are hidden!") } return if (isCancelable) isCanceled else false } diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt index 5bf8d7c2e..ba8a30e56 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzTickEvent.kt @@ -1,7 +1,8 @@ package at.hannibal2.skyhanni.events class LorenzTickEvent(private val tick: Int) : LorenzEvent() { + fun isMod(i: Int) = tick % i == 0 fun repeatSeconds(i: Int) = isMod(i * 20) -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/LorenzToolTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/LorenzToolTipEvent.kt index 9e18fced9..52a6dc1d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/LorenzToolTipEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/LorenzToolTipEvent.kt @@ -4,5 +4,6 @@ import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack class LorenzToolTipEvent(val slot: Slot, val itemStack: ItemStack, var toolTip: MutableList<String>) : LorenzEvent() { + fun toolTipRemovedPrefix() = toolTip.map { it.removePrefix("§5§o") } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt index 71c1cfa73..7d356707e 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PacketEvent.kt @@ -8,6 +8,7 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable * Note: This event is async and may not be executed on the main minecraft thread. */ abstract class PacketEvent : LorenzEvent() { + abstract val direction: Direction abstract val packet: Packet<*> @@ -15,6 +16,7 @@ abstract class PacketEvent : LorenzEvent() { * Note: This event is async and may not be executed on the main minecraft thread. */ data class ReceiveEvent(override val packet: Packet<*>) : PacketEvent() { + override val direction = Direction.INBOUND } @@ -22,10 +24,11 @@ abstract class PacketEvent : LorenzEvent() { * Note: This event is async and may not be executed on the main minecraft thread. */ data class SendEvent(override val packet: Packet<*>) : PacketEvent() { + override val direction = Direction.OUTBOUND } enum class Direction { INBOUND, OUTBOUND } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt index bd03261ea..123d5e881 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/PlaySoundEvent.kt @@ -7,5 +7,6 @@ import net.minecraftforge.fml.common.eventhandler.Cancelable @Cancelable class PlaySoundEvent(val soundName: String, val location: LorenzVec, val pitch: Float, val volume: Float) : LorenzEvent() { + val distanceToPlayer by lazy { location.distanceToPlayer() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt index 975990b86..68f42f43b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ReceiveParticleEvent.kt @@ -13,8 +13,9 @@ class ReceiveParticleEvent( val speed: Float, val offset: LorenzVec, val longDistance: Boolean, - val particleArgs: IntArray + val particleArgs: IntArray, ) : LorenzEvent() { + val distanceToPlayer by lazy { location.distanceToPlayer() } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt index 6a197de6c..d061becf9 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt @@ -111,8 +111,8 @@ class RenderEntityOutlineEvent(theType: Type?, potentialEntities: HashSet<Entity * [.NO_XRAY] means that this directly precedes entities whose outlines are rendered only when visible to the client
*/
enum class Type {
+
XRAY,
NO_XRAY
}
-
}
diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt index 8d841bcee..d9341cc87 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RenderItemTipEvent.kt @@ -6,10 +6,11 @@ class RenderItemTipEvent( val stack: ItemStack, var renderObjects: MutableList<RenderObject>, ) : LorenzEvent() { + var stackTip = "" set(value) { renderObjects.add(RenderObject(value, 0, 0)) } } -class RenderObject(val text: String, var offsetX: Int = 0, var offsetY: Int = 0)
\ No newline at end of file +class RenderObject(val text: String, var offsetX: Int = 0, var offsetY: Int = 0) diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt index ef4a55563..cfcdfb37b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RenderMobColoredEvent.kt @@ -2,5 +2,5 @@ package at.hannibal2.skyhanni.events import net.minecraft.entity.EntityLivingBase -//TODO remove -class RenderMobColoredEvent(val entity: EntityLivingBase, var color: Int) : LorenzEvent()
\ No newline at end of file +// TODO remove +class RenderMobColoredEvent(val entity: EntityLivingBase, var color: Int) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt index 2f96e4482..7768e6586 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ResetEntityHurtEvent.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.events import net.minecraft.entity.EntityLivingBase import java.awt.Color -//TODO remove +// TODO remove class ResetEntityHurtEvent(val entity: EntityLivingBase, var shouldReset: Boolean) : LorenzEvent() -fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff)
\ No newline at end of file +fun Color.withAlpha(alpha: Int): Int = (alpha.coerceIn(0, 255) shl 24) or (this.rgb and 0x00ffffff) diff --git a/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt index aa6101a62..aa81287d7 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/SackChangeEvent.kt @@ -5,5 +5,5 @@ import at.hannibal2.skyhanni.data.SackAPI class SackChangeEvent( val sackChanges: List<SackAPI.SackChange>, val otherItemsAdded: Boolean, - val otherItemsRemoved: Boolean + val otherItemsRemoved: Boolean, ) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt index 6d3d39299..0c0c4f627 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/SeaCreatureFishEvent.kt @@ -5,5 +5,5 @@ import at.hannibal2.skyhanni.features.fishing.SeaCreature class SeaCreatureFishEvent( val seaCreature: SeaCreature, val chatEvent: LorenzChatEvent, - val doubleHook: Boolean -) : LorenzEvent()
\ No newline at end of file + val doubleHook: Boolean, +) : LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt index b8ac2eb28..fae3399e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ServerBlockChangeEvent.kt @@ -7,19 +7,19 @@ import net.minecraft.block.state.IBlockState import net.minecraft.util.BlockPos class ServerBlockChangeEvent(private val blockPos: BlockPos, private val blockState: IBlockState) : LorenzEvent() { + val location by lazy { blockPos.toLorenzVec() } val old by lazy { location.getBlockAt().toString().getName() } val new by lazy { blockState.block.toString().getName() } companion object { + val pattern = "Block\\{minecraft:(?<name>.*)}".toPattern() private fun String.getName() = pattern.matchMatcher(this) { group("name") } ?: this - } - } |