aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/dulkirmod/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/dulkirmod/features')
-rw-r--r--src/main/kotlin/dulkirmod/features/ImpactDisplay.kt52
-rw-r--r--src/main/kotlin/dulkirmod/features/ReaperDisplay.kt52
-rw-r--r--src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt66
3 files changed, 135 insertions, 35 deletions
diff --git a/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt
new file mode 100644
index 0000000..e1d3f07
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/ImpactDisplay.kt
@@ -0,0 +1,52 @@
+package dulkirmod.features
+
+import net.minecraft.item.ItemStack
+import net.minecraft.nbt.NBTTagCompound
+import net.minecraftforge.client.event.sound.PlaySoundEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
+import kotlin.math.min
+
+object ImpactDisplay {
+
+ var lastImpact = 0L
+
+ fun shouldDisplay(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) {
+ if (!isBlade(stack)) return
+ cir.returnValue = System.currentTimeMillis() - lastImpact < 5000
+ }
+
+ fun calcDurability(stack: ItemStack, cir: CallbackInfoReturnable<Double>) {
+ if (!isBlade(stack)) return
+ val time = (System.currentTimeMillis() - lastImpact) / 5000.0
+ cir.returnValue = min(1.0, 1.0 - time)
+ }
+
+ @SubscribeEvent
+ fun onSound(event: PlaySoundEvent) {
+ if (event.name != "mob.zombie.remedy") return
+ if (event.sound.pitch != 0.6984127f) return
+ if (event.sound.volume != 1.0f) return
+ lastImpact = System.currentTimeMillis()
+ }
+
+ @SubscribeEvent
+ fun onWorldLoad(event: WorldEvent.Load) {
+ lastImpact = 0L
+ }
+
+ private fun isBlade(stack: ItemStack): Boolean {
+ if (stack.hasTagCompound()) {
+ val tag: NBTTagCompound = stack.tagCompound
+ if (tag.hasKey("ExtraAttributes", 10) && tag.hasKey("display", 10)) {
+ val ea: NBTTagCompound = tag.getCompoundTag("ExtraAttributes")
+ if (ea.hasKey("id", 8)) {
+ val id = ea.getString("id")
+ return id matches "(HYPERION|ASTRAEA|SCYLLA|VALKYRIE)".toRegex()
+ }
+ }
+ }
+ return false
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt
new file mode 100644
index 0000000..3fd743d
--- /dev/null
+++ b/src/main/kotlin/dulkirmod/features/ReaperDisplay.kt
@@ -0,0 +1,52 @@
+package dulkirmod.features
+
+import net.minecraft.item.ItemStack
+import net.minecraft.nbt.NBTTagCompound
+import net.minecraftforge.client.event.sound.PlaySoundEvent
+import net.minecraftforge.event.world.WorldEvent
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable
+import kotlin.math.min
+
+object ReaperDisplay {
+
+ var lastReaperUsage = 0L
+
+ fun shouldDisplay(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) {
+ if (!isReaper(stack)) return
+ cir.returnValue = System.currentTimeMillis() - lastReaperUsage < 25000
+ }
+
+ fun calcDurability(stack: ItemStack, cir: CallbackInfoReturnable<Double>) {
+ if (!isReaper(stack)) return
+ val time = (System.currentTimeMillis() - lastReaperUsage) / 25000.0
+ cir.returnValue = min(1.0, 1.0 - time)
+ }
+
+ @SubscribeEvent
+ fun onSound(event: PlaySoundEvent) {
+ if (event.name != "mob.zombie.remedy") return
+ if (event.sound.pitch != 1.0f) return
+ if (event.sound.volume != .5f) return
+ lastReaperUsage = System.currentTimeMillis()
+ }
+
+ @SubscribeEvent
+ fun onWorldLoad(event: WorldEvent) {
+ lastReaperUsage = 0L
+ }
+
+ private fun isReaper(stack: ItemStack): Boolean {
+ if (stack.hasTagCompound()) {
+ val tag: NBTTagCompound = stack.tagCompound
+ if (tag.hasKey("ExtraAttributes", 10) && tag.hasKey("display", 10)) {
+ val ea: NBTTagCompound = tag.getCompoundTag("ExtraAttributes")
+ if (ea.hasKey("id", 8)) {
+ val id = ea.getString("id")
+ return id matches "(REAPER_CHESTPLATE)|(REAPER_LEGGINGS)|(REAPER_BOOTS)".toRegex()
+ }
+ }
+ }
+ return false
+ }
+} \ No newline at end of file
diff --git a/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt b/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt
index 395d363..68a8659 100644
--- a/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt
+++ b/src/main/kotlin/dulkirmod/features/dungeons/ArcherHighlight.kt
@@ -1,43 +1,39 @@
package dulkirmod.features.dungeons
-import com.google.common.eventbus.Subscribe
import dulkirmod.DulkirMod.Companion.mc
import dulkirmod.config.DulkirConfig
import dulkirmod.utils.ScoreBoardUtils
import dulkirmod.utils.TabListUtils
import dulkirmod.utils.WorldRenderUtils
-import ibxm.Player
-import net.minecraft.entity.player.EntityPlayer
-import net.minecraftforge.client.event.RenderLivingEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.awt.Color
object ArcherHighlight {
-
-// @SubscribeEvent
-// fun onRenderLiving(event: RenderLivingEvent.Pre<*>) {
-// if (!DulkirConfig.archerBox) return
-// if (TabListUtils.area != "Dungeon") return
-// if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return
-// if (event.entity !is EntityPlayer) return
-// val name = event.entity.name ?: return
-// if (name != TabListUtils.archerName) return
-// if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return
-// if (mc.thePlayer.name == name) return
-// val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z)
-// WorldRenderUtils.drawCustomBox(
-// x - .5,
-// 1.0,
-// y,
-// 2.0,
-// z - .5,
-// 1.0,
-// DulkirConfig.archBoxColor.toJavaColor(),
-// 3f,
-// phase = false
-// )
-// }
+ /**The following code is broken but interesting because with SBA it makes RGB PEOPLE
+ @SubscribeEvent
+ fun onRenderLiving(event: RenderLivingEvent.Pre<*>) {
+ if (!DulkirConfig.archerBox) return
+ if (TabListUtils.area != "Dungeon") return
+ if (!ScoreBoardUtils.isInM7 && !DulkirConfig.archerBoxEverywhere) return
+ if (event.entity !is EntityPlayer) return
+ val name = event.entity.name ?: return
+ if (name != TabListUtils.archerName) return
+ if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return
+ if (mc.thePlayer.name == name) return
+ val (x, y, z) = WorldRenderUtils.fixRenderPos(event.x, event.y, event.z)
+ WorldRenderUtils.drawCustomBox(
+ x - .5,
+ 1.0,
+ y,
+ 2.0,
+ z - .5,
+ 1.0,
+ DulkirConfig.archBoxColor.toJavaColor(),
+ 3f,
+ phase = false
+ )
+ }
+ */
@SubscribeEvent
fun onRenderWorldLast(event: RenderWorldLastEvent) {
@@ -47,12 +43,12 @@ object ArcherHighlight {
val players = mc.theWorld.playerEntities.filterNotNull()
players.forEach {
val name = it.name ?: return@forEach
- if (name != TabListUtils.archerName) return
- if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return
- if (mc.thePlayer.name == name) return
- val x = it.posX - ((it.lastTickPosX - it.posX) * event.partialTicks)
- val y = it.posY - ((it.lastTickPosY - it.posY) * event.partialTicks)
- val z = it.posZ - ((it.lastTickPosZ - it.posZ) * event.partialTicks)
+ if (name != TabListUtils.archerName) return@forEach
+ if (mc.thePlayer.positionVector.yCoord > 45 && !DulkirConfig.archerBoxEverywhere) return@forEach
+ if (mc.thePlayer.name == name) return@forEach
+ val x = it.lastTickPosX + ((it.posX - it.lastTickPosX) * event.partialTicks)
+ val y = it.lastTickPosY + ((it.posY - it.lastTickPosY) * event.partialTicks)
+ val z = it.lastTickPosZ + ((it.posZ - it.lastTickPosZ) * event.partialTicks)
WorldRenderUtils.drawCustomBox(
x - .5,
1.0,