Skip to content

Commit

Permalink
feat: use nametag to detect slayer
Browse files Browse the repository at this point in the history
  • Loading branch information
My-Name-Is-Jeff committed Aug 16, 2024
1 parent 709b880 commit 29394b8
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ private void onSendPacket(Packet<?> packet, CallbackInfo 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)
);
if (entity != null) {
MasterMode7Features.INSTANCE.onMobSpawned(entity);
((ExtensionEntityLivingBase) entity).getSkytilsHook().onNewDisplayName(
entity.getDataWatcher().getWatchableObjectString(2)
);
}
}
}
10 changes: 10 additions & 0 deletions src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3490,6 +3490,16 @@ object Config : Vigilant(
)
var useSlayerHitMethod = true

@Property(
type = PropertyType.SWITCH, name = "Use Nametag to Detect Slayer",
description = "Finds your slayer based on the nametag.",
category = "Slayer", subcategory = "General",
i18nName = "skytils.config.slayer.general.use_nametag_to_detect_slayer",
i18nCategory = "skytils.config.slayer",
i18nSubcategory = "skytils.config.slayer.general"
)
var useNametagHitMethod = false

@Property(
type = PropertyType.SWITCH, name = "Ping when in Atoned Horror Danger Zone",
description = "Pings when you are standing on the Atoned Horror's TNT target.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.Tessellator
import net.minecraft.client.renderer.vertex.DefaultVertexFormats
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLiving
import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.boss.BossStatus
import net.minecraft.entity.boss.IBossDisplayData
Expand Down Expand Up @@ -352,6 +353,28 @@ object SlayerFeatures : CoroutineScope {
timerEntityChanged(newName)
}
}

if (hasSlayerText && slayer == null && Skytils.config.useNametagHitMethod) {
val entity = mc.theWorld?.getEntityByID(packet.entityId)
printDevMessage("entity is null?", "slayerspam")
if (entity != null && entity is EntityArmorStand) {
val name = packet.func_149376_c()?.find { it.dataValueId == 2 }?.`object` as? String
if (name != null) {
printDevMessage("Checking entity nametag $name, was empty ${entity.customNameTag.isEmpty()}", "slayerspam")
if (name.startsWith("§eSpawned by: ") && name.endsWith(mc.thePlayer.name)) {
printDevMessage("Detected spawned text", "slayerspam", "slayer")
mc.theWorld.getEntitiesWithinAABBExcludingEntity(entity, entity.entityBoundingBox.expand(0.5, 0.5, 0.5)).filter {
it is EntityLiving && (if (MayorInfo.allPerks.contains("DOUBLE MOBS HP!!!")) 2 else 1) * floor(it.baseMaxHealth).toInt() == expectedMaxHp
}.minByOrNull {
it.getDistanceSqToEntity(entity)
}?.let {
printDevMessage("Found entity from nametag", "slayerspam", "slayer")
processSlayerEntity(it)
}
}
}
}
}
}

if (packet is S29PacketSoundEffect) {
Expand Down Expand Up @@ -458,7 +481,9 @@ object SlayerFeatures : CoroutineScope {
printDevMessage("boss not null", "slayerspam", "seraphspam")
return
}
processSlayerEntity(event.entity)
if (!Skytils.config.useNametagHitMethod) {
processSlayerEntity(event.entity)
}
}

@SubscribeEvent
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/skytils/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ skytils.config.slayer..current_inferno_rng_meter=Current Inferno RNG Meter
skytils.config.slayer..current_bloodfiend_rng_meter=Current Bloodfiend RNG Meter
skytils.config.slayer.general.carry_mode=Carry Mode
skytils.config.slayer.general.use_hits_to_detect_slayer=Use Hits to Detect Slayer
skytils.config.slayer.general.use_nametag_to_detect_slayer=Use Nametag to Detect Slayer
skytils.config.slayer.quality_of_life.ping_when_in_atoned_horror_danger_zone=Ping when in Atoned Horror Danger Zone
skytils.config.slayer.quality_of_life.slayer_boss_hitbox=Slayer Boss Hitbox
skytils.config.slayer.quality_of_life.slayer_miniboss_spawn_alert=Slayer Miniboss Spawn Alert
Expand Down

0 comments on commit 29394b8

Please sign in to comment.