aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/lorenz/mod/HideNotClickableItems.kt4
-rw-r--r--src/main/java/at/lorenz/mod/LorenzDebug.kt13
-rw-r--r--src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt2
-rw-r--r--src/main/java/at/lorenz/mod/chat/ChatManager.kt11
-rw-r--r--src/main/java/at/lorenz/mod/config/LorenzConfig.kt1
-rw-r--r--src/main/java/at/lorenz/mod/dungeon/DungeonHighlightClickedBlocks.kt102
-rw-r--r--src/main/java/at/lorenz/mod/events/PacketEvent.kt25
-rw-r--r--src/main/java/at/lorenz/mod/mixinhooks/NetHandlerPlayClientHook.kt9
-rw-r--r--src/main/java/at/lorenz/mod/mixinhooks/NetworkManagerHook.kt10
-rw-r--r--src/main/java/at/lorenz/mod/mixins/MixinNetHandlerPlayClient.java34
-rw-r--r--src/main/java/at/lorenz/mod/mixins/MixinNetworkManager.java19
-rw-r--r--src/main/java/at/lorenz/mod/utils/BlockUtils.kt23
-rw-r--r--src/main/java/at/lorenz/mod/utils/LorenzVec.kt61
-rw-r--r--src/main/java/at/lorenz/mod/utils/RenderUtil.kt20
-rw-r--r--src/main/java/at/lorenz/mod/utils/RenderUtils.kt312
-rw-r--r--src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java2
-rw-r--r--src/main/resources/mixins.skyblockhud.json4
17 files changed, 624 insertions, 28 deletions
diff --git a/src/main/java/at/lorenz/mod/HideNotClickableItems.kt b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt
index 40c755fea..404390955 100644
--- a/src/main/java/at/lorenz/mod/HideNotClickableItems.kt
+++ b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt
@@ -2,14 +2,14 @@ package at.lorenz.mod
import at.lorenz.mod.bazaar.BazaarApi
import at.lorenz.mod.config.LorenzConfig
-import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes
import at.lorenz.mod.events.GuiContainerEvent
import at.lorenz.mod.utils.ItemUtils
import at.lorenz.mod.utils.ItemUtils.Companion.cleanName
import at.lorenz.mod.utils.ItemUtils.Companion.getLore
import at.lorenz.mod.utils.LorenzColor
import at.lorenz.mod.utils.LorenzUtils
-import at.lorenz.mod.utils.RenderUtil.Companion.highlight
+import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes
+import at.lorenz.mod.utils.RenderUtils.highlight
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.renderer.GlStateManager
diff --git a/src/main/java/at/lorenz/mod/LorenzDebug.kt b/src/main/java/at/lorenz/mod/LorenzDebug.kt
new file mode 100644
index 000000000..7687727a9
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/LorenzDebug.kt
@@ -0,0 +1,13 @@
+package at.lorenz.mod
+
+import at.lorenz.mod.utils.LorenzLogger
+
+object LorenzDebug {
+
+ private val logger = LorenzLogger("debug")
+
+ fun log(text: String) {
+ logger.log(text)
+ println("debug logger: $text")
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt
index 0daa12b7d..ba12838e2 100644
--- a/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt
+++ b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt
@@ -4,7 +4,7 @@ import at.lorenz.mod.config.LorenzConfig
import at.lorenz.mod.events.GuiContainerEvent
import at.lorenz.mod.utils.ItemUtils.Companion.getLore
import at.lorenz.mod.utils.LorenzColor
-import at.lorenz.mod.utils.RenderUtil.Companion.highlight
+import at.lorenz.mod.utils.RenderUtils.highlight
import net.minecraft.client.gui.inventory.GuiChest
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.inventory.ContainerChest
diff --git a/src/main/java/at/lorenz/mod/chat/ChatManager.kt b/src/main/java/at/lorenz/mod/chat/ChatManager.kt
index a85643e1b..878c4e8c0 100644
--- a/src/main/java/at/lorenz/mod/chat/ChatManager.kt
+++ b/src/main/java/at/lorenz/mod/chat/ChatManager.kt
@@ -2,8 +2,9 @@ package at.lorenz.mod.chat
import at.lorenz.mod.utils.LorenzLogger
import at.lorenz.mod.events.LorenzChatEvent
+import at.lorenz.mod.events.PacketEvent
import at.lorenz.mod.utils.LorenzUtils
-import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraft.network.play.server.S02PacketChat
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -15,11 +16,13 @@ class ChatManager {
private val loggerFilteredTypes = mutableMapOf<String, LorenzLogger>()
@SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true)
- fun onChatPacket(event: ClientChatReceivedEvent) {
- val messageComponent = event.message
+ fun onChatPacket(event: PacketEvent.ReceiveEvent) {
+ val packet = event.packet
+ if (packet !is S02PacketChat) return
+ val messageComponent = packet.chatComponent
val message = LorenzUtils.stripVanillaMessage(messageComponent.formattedText)
- if (event.type.toInt() == 2) {
+ if (packet.type.toInt() == 2) {
// val actionBarEvent = LorenzActionBarEvent(message)
// actionBarEvent.postAndCatch()
} else {
diff --git a/src/main/java/at/lorenz/mod/config/LorenzConfig.kt b/src/main/java/at/lorenz/mod/config/LorenzConfig.kt
index 67268b6ca..3877ec4e0 100644
--- a/src/main/java/at/lorenz/mod/config/LorenzConfig.kt
+++ b/src/main/java/at/lorenz/mod/config/LorenzConfig.kt
@@ -8,5 +8,6 @@ class LorenzConfig {
val hideNotClickableItems = true
val lorenzBazaarOrderHelper = true
+ val lorenzDungeonHighlightClickedBlocks = true
}
} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/dungeon/DungeonHighlightClickedBlocks.kt b/src/main/java/at/lorenz/mod/dungeon/DungeonHighlightClickedBlocks.kt
new file mode 100644
index 000000000..ce885df48
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/dungeon/DungeonHighlightClickedBlocks.kt
@@ -0,0 +1,102 @@
+package at.lorenz.mod.dungeon
+
+import at.lorenz.mod.config.LorenzConfig
+import at.lorenz.mod.events.LorenzChatEvent
+import at.lorenz.mod.events.PacketEvent
+import at.lorenz.mod.utils.*
+import at.lorenz.mod.utils.BlockUtils.getBlockAt
+import at.lorenz.mod.utils.RenderUtils.drawSkytilsColor
+import at.lorenz.mod.utils.RenderUtils.drawString
+import net.minecraft.init.Blocks
+import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DungeonHighlightClickedBlocks {
+
+ private val blocks = mutableListOf<ClickedBlock>()
+ private var colorIndex = 0
+ private val colors = listOf(LorenzColor.YELLOW, LorenzColor.AQUA, LorenzColor.GREEN, LorenzColor.LIGHT_PURPLE)
+
+ private fun getNextColor(): LorenzColor {
+ var id = colorIndex + 1
+ if (id == colors.size) id = 0
+ colorIndex = id
+ return colors[colorIndex]
+ }
+
+ @SubscribeEvent
+ fun onChatMessage(event: LorenzChatEvent) {
+ if (!LorenzConfig.lorenzDungeonHighlightClickedBlocks) return
+ //TODO add
+// if (!LorenzUtils.inDungeon) return
+
+ if (event.message == "§cYou hear the sound of something opening...") {
+ event.blockedReason = "dungeon_highlight_clicked_block"
+ }
+ }
+
+ @SubscribeEvent
+ fun onSendPacket(event: PacketEvent.SendEvent) {
+ if (!LorenzConfig.lorenzDungeonHighlightClickedBlocks) return
+ //TODO add
+// if (!LorenzUtils.inDungeon) return
+// TODO add
+// if (DungeonAPI.inBossRoom) return
+ if (event.packet !is C08PacketPlayerBlockPlacement || event.packet.stack == null) return
+
+ val position = event.packet.position.toLorenzVec()
+
+ if (blocks.any { it.position == position }) return
+
+ val type: ClickedBlockType = when (position.getBlockAt()) {
+ Blocks.chest, Blocks.trapped_chest -> ClickedBlockType.CHEST
+ Blocks.lever -> ClickedBlockType.LEVER
+ Blocks.skull -> ClickedBlockType.WITHER_ESSENCE
+ else -> return
+ }
+
+ if (type == ClickedBlockType.WITHER_ESSENCE) {
+ val text = BlockUtils.getSkinFromSkull(position.toBlocPos())
+ if (text != "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQ" +
+ "ubmV0L3RleHR1cmUvYzRkYjRhZGZhOWJmNDhmZjVkNDE3M" +
+ "DdhZTM0ZWE3OGJkMjM3MTY1OWZjZDhjZDg5MzQ3NDlhZjRjY2U5YiJ9fX0="
+ ) {
+ return
+ }
+ }
+
+// if (nearWaterRoom() && type == ClickedBlockType.LEVER) return
+
+ val color = getNextColor()
+ val displayText = color.getChatColor() + "Clicked " + type.display
+ blocks.add(ClickedBlock(position, displayText, color, System.currentTimeMillis()))
+ }
+
+ @SubscribeEvent
+ fun onWorldRender(event: RenderWorldLastEvent) {
+ if (!LorenzConfig.lorenzDungeonHighlightClickedBlocks) return
+ //TODO add
+// if (!LorenzUtils.inDungeon) return
+
+ blocks.removeAll { System.currentTimeMillis() > it.time + 3000 }
+ blocks.forEach {
+ event.drawSkytilsColor(it.position, it.color)
+ event.drawString(it.position.add(0.5, 0.5, 0.5), it.displayText, true)
+ }
+ }
+
+ class ClickedBlock(val position: LorenzVec, val displayText: String, val color: LorenzColor, val time: Long)
+
+ enum class ClickedBlockType(val display: String) {
+ LEVER("Lever"),
+ CHEST("Chest"),
+ WITHER_ESSENCE("Wither Essence"),
+ }
+
+// private fun nearWaterRoom(): Boolean {
+// val playerLoc =
+// LocationUtils.getPlayerLocation().add(LocationUtils.getPlayerLookingAtDirection().multiply(2)).add(0, 2, 0)
+// return WaterBoardSolver.waterRoomDisplays.any { it.distance(playerLoc) < 3 }
+// }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/events/PacketEvent.kt b/src/main/java/at/lorenz/mod/events/PacketEvent.kt
new file mode 100644
index 000000000..3b8a26038
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/events/PacketEvent.kt
@@ -0,0 +1,25 @@
+package at.lorenz.mod.events
+
+import net.minecraft.network.Packet
+import net.minecraftforge.fml.common.eventhandler.Cancelable
+
+@Cancelable
+open class PacketEvent(val packet: Packet<*>) : LorenzEvent() {
+ var direction: Direction? = null
+
+ class ReceiveEvent(packet: Packet<*>) : PacketEvent(packet) {
+ init {
+ direction = Direction.INBOUND
+ }
+ }
+
+ class SendEvent(packet: Packet<*>) : PacketEvent(packet) {
+ init {
+ direction = Direction.OUTBOUND
+ }
+ }
+
+ enum class Direction {
+ INBOUND, OUTBOUND
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/mixinhooks/NetHandlerPlayClientHook.kt b/src/main/java/at/lorenz/mod/mixinhooks/NetHandlerPlayClientHook.kt
new file mode 100644
index 000000000..41a59201e
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/mixinhooks/NetHandlerPlayClientHook.kt
@@ -0,0 +1,9 @@
+package at.lorenz.mod.mixinhooks
+
+import at.lorenz.mod.events.PacketEvent
+import net.minecraft.network.Packet
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
+
+fun onSendPacket(packet: Packet<*>, ci: CallbackInfo) {
+ if (PacketEvent.SendEvent(packet).postAndCatch()) ci.cancel()
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/mixinhooks/NetworkManagerHook.kt b/src/main/java/at/lorenz/mod/mixinhooks/NetworkManagerHook.kt
new file mode 100644
index 000000000..5f18be8d5
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/mixinhooks/NetworkManagerHook.kt
@@ -0,0 +1,10 @@
+package at.lorenz.mod.mixinhooks
+
+import at.lorenz.mod.events.PacketEvent
+import io.netty.channel.ChannelHandlerContext
+import net.minecraft.network.Packet
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo
+
+fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) {
+ if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel()
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/mixins/MixinNetHandlerPlayClient.java b/src/main/java/at/lorenz/mod/mixins/MixinNetHandlerPlayClient.java
new file mode 100644
index 000000000..9944a83ac
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/mixins/MixinNetHandlerPlayClient.java
@@ -0,0 +1,34 @@
+package at.lorenz.mod.mixins;
+
+import at.lorenz.mod.mixinhooks.NetHandlerPlayClientHookKt;
+import net.minecraft.client.multiplayer.WorldClient;
+import net.minecraft.client.network.NetHandlerPlayClient;
+import net.minecraft.entity.Entity;
+import net.minecraft.network.Packet;
+import net.minecraft.network.play.INetHandlerPlayClient;
+import net.minecraft.network.play.server.S0FPacketSpawnMob;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(value = NetHandlerPlayClient.class, priority = 1001)
+public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient {
+ @Shadow
+ private WorldClient clientWorldController;
+
+ @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true)
+ private void onSendPacket(Packet<?> packet, CallbackInfo ci) {
+ NetHandlerPlayClientHookKt.onSendPacket(packet, ci);
+ }
+
+// @Inject(method = "handleSpawnMob", at = @At("TAIL"))
+// private void onHandleSpawnMobTail(S0FPacketSpawnMob packetIn, CallbackInfo ci) {
+// Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityID());
+// MasterMode7Features.INSTANCE.onMobSpawned(entity);
+// ((ExtensionEntityLivingBase) entity).getSkytilsHook().onNewDisplayName(
+// entity.getDataWatcher().getWatchableObjectString(2)
+// );
+// }
+}
diff --git a/src/main/java/at/lorenz/mod/mixins/MixinNetworkManager.java b/src/main/java/at/lorenz/mod/mixins/MixinNetworkManager.java
new file mode 100644
index 000000000..c2314201b
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/mixins/MixinNetworkManager.java
@@ -0,0 +1,19 @@
+package at.lorenz.mod.mixins;
+
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.SimpleChannelInboundHandler;
+import net.minecraft.network.NetworkManager;
+import net.minecraft.network.Packet;
+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.CallbackInfo;
+import at.lorenz.mod.mixinhooks.NetworkManagerHookKt;
+
+@Mixin(value = NetworkManager.class, priority = 1001)
+public abstract class MixinNetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
+ @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true)
+ private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) {
+ NetworkManagerHookKt.onReceivePacket(context, packet, ci);
+ }
+}
diff --git a/src/main/java/at/lorenz/mod/utils/BlockUtils.kt b/src/main/java/at/lorenz/mod/utils/BlockUtils.kt
new file mode 100644
index 000000000..d16194c70
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/utils/BlockUtils.kt
@@ -0,0 +1,23 @@
+package at.lorenz.mod.utils
+
+import net.minecraft.block.Block
+import net.minecraft.client.Minecraft
+import net.minecraft.tileentity.TileEntitySkull
+import net.minecraft.util.BlockPos
+import net.minecraftforge.common.util.Constants
+
+object BlockUtils {
+
+ fun LorenzVec.getBlockAt(): Block =
+ Minecraft.getMinecraft().theWorld.getBlockState(toBlocPos()).block
+
+ fun LorenzVec.isInLoadedChunk(): Boolean =
+ Minecraft.getMinecraft().theWorld.chunkProvider.provideChunk(toBlocPos()).isLoaded
+
+ fun getSkinFromSkull(position: BlockPos?): String? {
+ val entity = Minecraft.getMinecraft().theWorld.getTileEntity(position) as TileEntitySkull
+ val serializeNBT = entity.serializeNBT()
+ return serializeNBT.getCompoundTag("Owner").getCompoundTag("Properties")
+ .getTagList("textures", Constants.NBT.TAG_COMPOUND).getCompoundTagAt(0).getString("Value")
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/utils/LorenzVec.kt b/src/main/java/at/lorenz/mod/utils/LorenzVec.kt
new file mode 100644
index 000000000..7dc29b369
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/utils/LorenzVec.kt
@@ -0,0 +1,61 @@
+package at.lorenz.mod.utils
+
+import net.minecraft.entity.Entity
+import net.minecraft.util.BlockPos
+import net.minecraft.util.Vec3
+import kotlin.math.pow
+
+data class LorenzVec(
+ val x: Double,
+ val y: Double,
+ val z: Double
+) {
+ constructor(x: Int, y: Int, z: Int) : this(x.toDouble(), y.toDouble(), z.toDouble())
+
+ fun toBlocPos(): BlockPos = BlockPos(x, y, z)
+
+ fun toVec3(): Vec3 = Vec3(x, y, z)
+
+ fun distance(other: LorenzVec): Double = distanceSq(other).pow(0.5)
+
+ fun distanceSq(x: Double, y: Double, z: Double): Double = distanceSq(LorenzVec(x, y, z))
+
+ fun distance(x: Double, y: Double, z: Double): Double = distance(LorenzVec(x, y, z))
+
+ fun distanceSq(other: LorenzVec): Double {
+ val dx = (other.x - x)
+ val dy = (other.y - y)
+ val dz = (other.z - z)
+ return (dx * dx + dy * dy + dz * dz)
+ }
+
+ fun add(x: Double, y: Double, z: Double): LorenzVec = LorenzVec(this.x + x, this.y + y, this.z + z)
+
+ fun add(x: Int, y: Int, z: Int): LorenzVec = LorenzVec(this.x + x, this.y + y, this.z + z)
+
+ override fun toString(): String {
+ return "LorenzVec{" +
+ "x=" + x +
+ ", y=" + y +
+ ", z=" + z +
+ '}'
+ }
+
+ fun multiply(d: Double): LorenzVec = LorenzVec(x multiplyZeroSave d, y multiplyZeroSave d, z multiplyZeroSave d)
+
+ fun multiply(d: Int): LorenzVec =
+ LorenzVec(x multiplyZeroSave d.toDouble(), y multiplyZeroSave d.toDouble(), z multiplyZeroSave d.toDouble())
+
+ fun add(other: LorenzVec) = LorenzVec(x + other.x, y + other.y, z + other.z)
+}
+
+private infix fun Double.multiplyZeroSave(other: Double): Double {
+ val result = this * other
+ return if (result == -0.0) 0.0 else result
+}
+
+fun BlockPos.toLorenzVec(): LorenzVec = LorenzVec(x, y, z)
+
+fun Entity.getLorenzVec(): LorenzVec = LorenzVec(posX, posY, posZ)
+
+fun Vec3.toLorenzVec(): LorenzVec = LorenzVec(xCoord, yCoord, zCoord) \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/utils/RenderUtil.kt b/src/main/java/at/lorenz/mod/utils/RenderUtil.kt
deleted file mode 100644
index e633461a4..000000000
--- a/src/main/java/at/lorenz/mod/utils/RenderUtil.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-package at.lorenz.mod.utils
-
-import net.minecraft.client.gui.Gui
-import net.minecraft.inventory.Slot
-
-class RenderUtil {
-
- companion object {
-
- infix fun Slot.highlight(color: LorenzColor) {
- Gui.drawRect(
- this.xDisplayPosition,
- this.yDisplayPosition,
- this.xDisplayPosition + 16,
- this.yDisplayPosition + 16,
- color.toColor().rgb
- )
- }
- }
-} \ No newline at end of file
diff --git a/src/main/java/at/lorenz/mod/utils/RenderUtils.kt b/src/main/java/at/lorenz/mod/utils/RenderUtils.kt
new file mode 100644
index 000000000..17532c613
--- /dev/null
+++ b/src/main/java/at/lorenz/mod/utils/RenderUtils.kt
@@ -0,0 +1,312 @@
+package at.lorenz.mod.utils
+
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.Gui
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraft.client.renderer.Tessellator
+import net.minecraft.client.renderer.vertex.DefaultVertexFormats
+import net.minecraft.inventory.Slot
+import net.minecraft.util.AxisAlignedBB
+import net.minecraft.util.MathHelper
+import net.minecraft.util.ResourceLocation
+import net.minecraftforge.client.event.RenderWorldLastEvent
+import org.lwjgl.opengl.GL11
+import java.awt.Color
+import kotlin.math.cos
+import kotlin.math.sin
+import kotlin.math.sqrt
+
+object RenderUtils {
+
+ val beaconBeam = ResourceLocation("textures/entity/beacon_beam.png")
+
+ infix fun Slot.highlight(color: LorenzColor) {
+ Gui.drawRect(
+ this.xDisplayPosition,
+ this.yDisplayPosition,
+ this.xDisplayPosition + 16,
+ this.yDisplayPosition + 16,
+ color.toColor().rgb
+ )
+ }
+
+ fun RenderWorldLastEvent.drawSkytilsColor(location: LorenzVec, color: LorenzColor, beacon: Boolean = false) {
+ val (viewerX, viewerY, viewerZ) = getViewerPos(partialTicks)
+ val x = location.x - viewerX
+ val y = location.y - viewerY
+ val z = location.z - viewerZ
+ val distSq = x * x + y * y + z * z
+ GlStateManager.disableDepth()
+ GlStateManager.disableCull()
+ drawFilledBoundingBox(
+ AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1).expandBlock(),
+ color.toColor(),
+ (0.1f + 0.005f * distSq.toFloat()).coerceAtLeast(0.2f)
+ )
+ GlStateManager.disableTexture2D()
+ if (distSq > 5 * 5 && beacon) renderBeaconBeam(x, y + 1, z, color.toColor().rgb, 1.0f, partialTicks)
+ GlStateManager.disableLighting()
+ GlStateManager.enableTexture2D()
+ GlStateManager.enableDepth()
+ GlStateManager.enableCull()
+ }
+
+
+ fun getViewerPos(partialTicks: Float): LorenzVec {
+ val viewer = Minecraft.getMinecraft().renderViewEntity
+ val viewerX = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partialTicks
+ val viewerY = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partialTicks
+ val viewerZ = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partialTicks
+ return LorenzVec(viewerX, viewerY, viewerZ)
+ }
+
+ /**
+ * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
+ * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
+ * @author Moulberry
+ * @author Mojang
+ */
+ private fun drawFilledBoundingBox(aabb: AxisAlignedBB, c: Color, alphaMultiplier: Float = 1f) {
+ GlStateManager.enableBlend()
+ GlStateManager.disableLighting()
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
+ GlStateManager.disableTexture2D()
+ val tessellator = Tessellator.getInstance()
+ val worldRenderer = tessellator.worldRenderer
+ GlStateManager.color(c.red / 255f, c.green / 255f, c.blue / 255f, c.alpha / 255f * alphaMultiplier)
+
+ //vertical
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex()
+ tessellator.draw()
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex()
+ tessellator.draw()
+ GlStateManager.color(
+ c.red / 255f * 0.8f,
+ c.green / 255f * 0.8f,
+ c.blue / 255f * 0.8f,
+ c.alpha / 255f * alphaMultiplier
+ )
+
+ //x
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex()
+ tessellator.draw()
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex()
+ tessellator.draw()
+ GlStateManager.color(
+ c.red / 255f * 0.9f,
+ c.green / 255f * 0.9f,
+ c.blue / 255f * 0.9f,
+ c.alpha / 255f * alphaMultiplier
+ )
+ //z
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.minZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.minZ).endVertex()
+ tessellator.draw()
+ worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION)
+ worldRenderer.pos(aabb.minX, aabb.minY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.minY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.maxX, aabb.maxY, aabb.maxZ).endVertex()
+ worldRenderer.pos(aabb.minX, aabb.maxY, aabb.maxZ).endVertex()
+ tessellator.draw()
+ GlStateManager.enableTexture2D()
+ GlStateManager.disableBlend()
+ }
+
+ fun AxisAlignedBB.expandBlock() = expand(0.0020000000949949026, 0.0020000000949949026, 0.0020000000949949026)
+
+ /**
+ * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0
+ * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE
+ * @author Moulberry
+ * @author Mojang
+ */
+ fun renderBeaconBeam(x: Double, y: Double, z: Double, rgb: Int, alphaMultiplier: Float, partialTicks: Float) {
+ val height = 300
+ val bottomOffset = 0
+ val topOffset = bottomOffset + height
+ val tessellator = Tessellator.getInstance()
+ val worldrenderer = tessellator.worldRenderer
+ Minecraft.getMinecraft().textureManager.bindTexture(beaconBeam)
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0f)
+ GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0f)
+ GlStateManager.disableLighting()
+ GlStateManager.enableCull()
+ GlStateManager.enableTexture2D()
+ GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0)
+ GlStateManager.enableBlend()
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
+ val time = Minecraft.getMinecraft().theWorld.totalWorldTime + partialTicks.toDouble()
+ val d1 = MathHelper.func_181162_h(
+ -time * 0.2 - MathHelper.floor_double(-time * 0.1)
+ .toDouble()
+ )
+ val r = (rgb shr 16 and 0xFF) / 255f
+ val g = (rgb shr 8 and 0xFF) / 255f
+ val b = (rgb and 0xFF) / 255f
+ val d2 = time * 0.025 * -1.5
+ val d4 = 0.5 + cos(d2 + 2.356194490192345) * 0.2
+ val d5 = 0.5 + sin(d2 + 2.356194490192345) * 0.2
+ val d6 = 0.5 + cos(d2 + Math.PI / 4.0) * 0.2
+ val d7 = 0.5 + sin(d2 + Math.PI / 4.0) * 0.2
+ val d8 = 0.5 + cos(d2 + 3.9269908169872414) * 0.2
+ val d9 = 0.5 + sin(d2 + 3.9269908169872414) * 0.2
+ val d10 = 0.5 + cos(d2 + 5.497787143782138) * 0.2
+ val d11 = 0.5 + sin(d2 + 5.497787143782138) * 0.2
+ val d14 = -1.0 + d1
+ val d15 = height.toDouble() * 2.5 + d14
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR)
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0, d14).color(r, g, b, 1.0f).endVertex()
+ worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0, d15).color(r, g, b, 1.0f * alphaMultiplier)
+ .endVertex()
+ tessellator.draw()
+ GlStateManager.disableCull()
+ val d12 = -1.0 + d1
+ val d13 = height + d12
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR)
+ worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.8, y + topOffset, z + 0.2).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.2).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.8, y + bottomOffset, z + 0.8).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.8, y + topOffset, z + 0.8).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.2, y + topOffset, z + 0.8).tex(1.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.8).tex(1.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.2, y + bottomOffset, z + 0.2).tex(0.0, d12).color(r, g, b, 0.25f).endVertex()
+ worldrenderer.pos(x + 0.2, y + topOffset, z + 0.2).tex(0.0, d13).color(r, g, b, 0.25f * alphaMultiplier)
+ .endVertex()
+ tessellator.draw()
+ }
+
+ fun RenderWorldLastEvent.drawString(location: LorenzVec, text: String, seeThroughBlocks: Boolean = false) {
+ GlStateManager.alphaFunc(516, 0.1f)
+ GlStateManager.pushMatrix()
+ val viewer = Minecraft.getMinecraft().renderViewEntity
+ val renderManager = Minecraft.getMinecraft().renderManager
+ var x = location.x - renderManager.viewerPosX
+ var y = location.y - renderManager.viewerPosY - viewer.eyeHeight
+ var z = location.z - renderManager.viewerPosZ
+ val distSq = x * x + y * y + z * z
+ val dist = sqrt(distSq)
+ if (distSq > 144) {
+ x *= 12 / dist
+ y *= 12 / dist
+ z *= 12 / dist
+ }
+
+ if (seeThroughBlocks) {
+ GlStateManager.disableDepth()
+ GlStateManager.disableCull()
+ }
+
+ GlStateManager.translate(x, y, z)
+ GlStateManager.translate(0f, viewer.eyeHeight, 0f)
+ drawNametag(text)
+ GlStateManager.rotate(-renderManager.playerViewY, 0.0f, 1.0f, 0.0f)
+ GlStateManager.rotate(renderManager.playerViewX, 1.0f, 0.0f, 0.0f)
+ GlStateManager.translate(0f, -0.25f, 0f)
+ GlStateManager.rotate(-renderManager.playerViewX, 1.0f, 0.0f, 0.0f)
+ GlStateManager.rotate(renderManager.playerViewY, 0.0f, 1.0f, 0.0f)
+// RenderUtil.drawNametag(EnumChatFormatting.YELLOW.toString() + dist.roundToInt() + "m")
+ GlStateManager.popMatrix()
+ GlStateManager.disableLighting()
+
+
+ if (seeThroughBlocks) {
+ GlStateManager.enableDepth()
+ GlStateManager.enableCull()
+ }
+ }
+
+ /**
+ * @author Mojang
+ */
+ fun drawNametag(str: String?) {
+ val fontRenderer = Minecraft.getMinecraft().fontRendererObj
+ val f1 = 0.02666667f
+ GlStateManager.pushMatrix()
+ GL11.glNormal3f(0.0f, 1.0f, 0.0f)
+ GlStateManager.rotate(-Minecraft.getMinecraft().renderManager.playerViewY, 0.0f, 1.0f, 0.0f)
+ GlStateManager.rotate(
+ Minecraft.getMinecraft().renderManager.playerViewX,
+ 1.0f,
+ 0.0f,
+ 0.0f
+ )
+ GlStateManager.scale(-f1, -f1, f1)
+ GlStateManager.disableLighting()
+ GlStateManager.depthMask(false)
+ GlStateManager.enableBlend()
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)
+ val tessellator = Tessellator.getInstance()
+ val worldrenderer = tessellator.worldRenderer
+ val i = 0
+ val j = fontRenderer.getStringWidth(str) / 2
+ GlStateManager.disableTexture2D()
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR)
+ worldrenderer.pos((-j - 1).toDouble(), (-1 + i).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex()
+ worldrenderer.pos((-j - 1).toDouble(), (8 + i).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex()
+ worldrenderer.pos((j + 1).toDouble(), (8 + i).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex()
+ worldrenderer.pos((j + 1).toDouble(), (-1 + i).toDouble(), 0.0).color(0.0f, 0.0f, 0.0f, 0.25f).endVertex()
+ tessellator.draw()
+ GlStateManager.enableTexture2D()
+ fontRenderer.drawString(str, -j, i, 553648127)
+ GlStateManager.depthMask(true)
+ fontRenderer.drawString(str, -j, i, -1)
+ GlStateManager.enableBlend()
+ GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
+ GlStateManager.popMatrix()
+ }
+} \ No newline at end of file
diff --git a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
index fa55cf3ad..d1165d39f 100644
--- a/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
+++ b/src/main/java/com/thatgravyboat/skyblockhud/SkyblockHud.java
@@ -6,6 +6,7 @@ import at.lorenz.mod.bazaar.BazaarOrderHelper;
import at.lorenz.mod.chat.ChatFilter;
import at.lorenz.mod.chat.ChatManager;
import at.lorenz.mod.dungeon.DungeonChatFilter;
+import at.lorenz.mod.dungeon.DungeonHighlightClickedBlocks;
import com.thatgravyboat.skyblockhud.config.SBHConfig;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.common.MinecraftForge;
@@ -41,6 +42,7 @@ public class SkyblockHud {
MinecraftForge.EVENT_BUS.register(new ChatFilter());
MinecraftForge.EVENT_BUS.register(new DungeonChatFilter());
MinecraftForge.EVENT_BUS.register(new HideNotClickableItems());
+ MinecraftForge.EVENT_BUS.register(new DungeonHighlightClickedBlocks());
// MinecraftForge.EVENT_BUS.register(new LeaderboardGetter());
diff --git a/src/main/resources/mixins.skyblockhud.json b/src/main/resources/mixins.skyblockhud.json
index d78ee962f..4ff945a3e 100644
--- a/src/main/resources/mixins.skyblockhud.json
+++ b/src/main/resources/mixins.skyblockhud.json
@@ -3,6 +3,8 @@
"refmap": "mixins.skyblockhud.refmap.json",
"compatibilityLevel": "JAVA_8",
"mixins": [
- "MixinGuiContainer"
+ "MixinGuiContainer",
+ "MixinNetworkManager",
+ "MixinNetHandlerPlayClient"
]
}