diff --git a/src/main/java/gg/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java b/src/main/java/gg/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java index 8da4274ce..edd71f9d8 100644 --- a/src/main/java/gg/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java +++ b/src/main/java/gg/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java @@ -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) + ); + } } } diff --git a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt index ec80224f7..348bd04c2 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/core/Config.kt @@ -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.", diff --git a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/slayer/SlayerFeatures.kt b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/slayer/SlayerFeatures.kt index bfc94159e..792cb235d 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/features/impl/slayer/SlayerFeatures.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/features/impl/slayer/SlayerFeatures.kt @@ -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 @@ -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) { @@ -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 diff --git a/src/main/resources/assets/skytils/lang/en_US.lang b/src/main/resources/assets/skytils/lang/en_US.lang index c9f98c2e5..2ba6b3656 100644 --- a/src/main/resources/assets/skytils/lang/en_US.lang +++ b/src/main/resources/assets/skytils/lang/en_US.lang @@ -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