diff options
Diffstat (limited to 'src')
6 files changed, 91 insertions, 4 deletions
diff --git a/src/main/kotlin/com/dulkirfabric/Registrations.kt b/src/main/kotlin/com/dulkirfabric/Registrations.kt index 34bb124..208a267 100644 --- a/src/main/kotlin/com/dulkirfabric/Registrations.kt +++ b/src/main/kotlin/com/dulkirfabric/Registrations.kt @@ -77,6 +77,7 @@ object Registrations { EVENT_BUS.subscribe(ActionBarUtil) EVENT_BUS.subscribe(ActionBarHudReplacements) EVENT_BUS.subscribe(ChatStacking) + EVENT_BUS.subscribe(AotvHighlight) if (FabricLoader.getInstance().isDevelopmentEnvironment) EVENT_BUS.subscribe(RenderTest) diff --git a/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt b/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt new file mode 100644 index 0000000..b56c82a --- /dev/null +++ b/src/main/kotlin/com/dulkirfabric/features/AotvHighlight.kt @@ -0,0 +1,75 @@ +package com.dulkirfabric.features + +import com.dulkirfabric.DulkirModFabric.mc +import com.dulkirfabric.events.ClientTickEvent +import com.dulkirfabric.events.LongUpdateEvent +import com.dulkirfabric.events.WorldRenderLastEvent +import com.dulkirfabric.util.render.WorldRenderUtils +import meteordevelopment.orbit.EventHandler +import net.minecraft.client.MinecraftClient +import net.minecraft.client.util.InputUtil +import net.minecraft.entity.Entity +import net.minecraft.util.hit.BlockHitResult +import net.minecraft.util.hit.HitResult +import net.minecraft.util.math.Vec3d +import net.minecraft.world.RaycastContext +import org.lwjgl.glfw.GLFW +import java.awt.Color + +object AotvHighlight { + private var heldItemID = "" + + @EventHandler + fun onTick(event: ClientTickEvent) { + heldItemID = getHeldItemID() + } + + fun getHeldItemID(): String { + val stack = mc.player?.mainHandStack ?: return "" + val tag = stack.nbt ?: return "" + val id = tag.getCompound("ExtraAttributes").get("id") ?: return "" + return id.toString().trim('"') + } + + @EventHandler + fun onLong(event: LongUpdateEvent) { + //println(heldItemID) + } + + @EventHandler + fun onWorldRenderLast(event: WorldRenderLastEvent) { + // check that holding aotv + if (heldItemID != "ASPECT_OF_THE_VOID") return + val handle = MinecraftClient.getInstance().window.handle + if (!InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT_SHIFT)) return + + // Find the targeted block with a range of 60.9 + val entity = mc.cameraEntity + if (mc.player == null) return + val blockHit = raycast(entity!!, 60.9, mc.tickDelta) + if (blockHit.type != HitResult.Type.BLOCK) return + val pos = (blockHit as BlockHitResult).blockPos + + // if found display box + WorldRenderUtils.drawBox(event.context, pos.x.toDouble(), pos.y.toDouble(), pos.z.toDouble(), 1.0, 1.0, 1.0, + Color(255, 1, 1, 255), false) + } + + private fun raycast(entity: Entity, maxDistance: Double, tickDelta: Float): HitResult { + // 1.7 if not crouch, 1.54 if crouch + val crouching = mc.player!!.isSneaking + var vec3d: Vec3d = mc.player!!.pos.add(0.0, if (crouching) 1.54 else 1.7, 0.0) + val vec3d2: Vec3d = entity.getRotationVec(tickDelta) + val vec3d3 = vec3d.add(vec3d2.x * maxDistance, vec3d2.y * maxDistance, vec3d2.z * maxDistance) + return mc.world!! + .raycast( + RaycastContext( + vec3d, + vec3d3, + RaycastContext.ShapeType.OUTLINE, + RaycastContext.FluidHandling.ANY, + entity + ) + ) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt index 2188bf4..9bdfa13 100644 --- a/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt +++ b/src/main/kotlin/com/dulkirfabric/features/CooldownDisplays.kt @@ -5,6 +5,7 @@ import com.dulkirfabric.events.PlaySoundEvent import com.dulkirfabric.events.WorldLoadEvent import com.dulkirfabric.util.SoundInfo import com.dulkirfabric.util.TrackedCooldown +import com.dulkirfabric.util.Utils import meteordevelopment.orbit.EventHandler import net.minecraft.item.ItemStack import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable @@ -19,6 +20,10 @@ object CooldownDisplays { Pair( SoundInfo("entity.zombie_villager.cure", 0.6984127f, 1f), TrackedCooldown("(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex(), 5000, 0) + ), + Pair( + SoundInfo("entity.firework_rocket.launch", 1f, 3f), + TrackedCooldown("SOS_FLARE".toRegex(), 20000, 0) ) ) @@ -34,6 +39,7 @@ object CooldownDisplays { @EventHandler fun onSound(event: PlaySoundEvent) { if (!DulkirConfig.configOptions.duraCooldown) return + // Utils.debugSound(event) val path = event.sound.id.path val pitch = event.sound.pitch val volume = event.sound.volume diff --git a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt index 5eda0f9..179ad3d 100644 --- a/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt +++ b/src/main/kotlin/com/dulkirfabric/features/RenderTest.kt @@ -2,6 +2,7 @@ package com.dulkirfabric.features import com.dulkirfabric.events.EntityLoadEvent import com.dulkirfabric.events.WorldRenderLastEvent +import com.dulkirfabric.util.render.GlowingEntityInterface import com.dulkirfabric.util.render.WorldRenderUtils import meteordevelopment.orbit.EventHandler import net.minecraft.text.Style @@ -18,12 +19,12 @@ object RenderTest { Vec3d(-183.5, 79.0, -465.5) ) - WorldRenderUtils.drawBox(event.context, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, Color(0, 200, 200, 150), false) + WorldRenderUtils.drawBox(event.context, 16.0, 119.0, -6.0, 2.0, 2.0, 2.0, Color(0, 200, 200, 150), false) } @EventHandler fun onLoadEnt(event: EntityLoadEvent) { - //if (event.entity !is GlowingEntityInterface) return - //event.entity.setDulkirEntityGlow(true, Color(0, 0, 255, 255),false) + if (event.entity !is GlowingEntityInterface) return + event.entity.setDulkirEntityGlow(true, Color(0, 0, 255, 255)) } }
\ No newline at end of file diff --git a/src/main/kotlin/com/dulkirfabric/util/Utils.kt b/src/main/kotlin/com/dulkirfabric/util/Utils.kt index ae98cf6..4ceb8c4 100644 --- a/src/main/kotlin/com/dulkirfabric/util/Utils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/Utils.kt @@ -11,6 +11,9 @@ object Utils { * Prints relevant information about a sound that is being displayed */ fun debugSound(event: PlaySoundEvent) { + if (event.sound.id.path == "entity.player.hurt" + && event.sound.pitch == 0f + && event.sound.volume == 0f) return println("Path: ${event.sound.id.path}") println("Pitch: ${event.sound.pitch}") println("Volume: ${event.sound.volume}") diff --git a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt index 54ccd01..d779c23 100644 --- a/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt +++ b/src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt @@ -15,6 +15,7 @@ import org.joml.Vector3f import org.lwjgl.opengl.GL11 import java.awt.Color import kotlin.math.max +import kotlin.math.min import kotlin.math.pow import kotlin.math.sqrt @@ -380,7 +381,7 @@ object WorldRenderUtils { matrices.push() matrices.translate(x - context.camera().pos.x, y - context.camera().pos.y, z - context.camera().pos.z) WorldRenderer.renderFilledBox(matrices, tes.buffer, 0.0, 0.0, 0.0, width, height, depth, - color.red.toFloat(), color.green.toFloat(), color.blue.toFloat(), color.alpha.toFloat()) + color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f) tes.draw() RenderSystem.enableDepthTest() matrices.pop() |