Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slayer System rework #1040

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
TheEnd.eyes = 0;
})
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.otherLocations.end.muteEndermanSounds"))
.binding(defaults.otherLocations.end.muteEndermanSounds,
() -> config.otherLocations.end.muteEndermanSounds,
newValue -> config.otherLocations.end.muteEndermanSounds = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Spider's Den
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
import de.hysky.skyblocker.config.ConfigUtils;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.configs.SlayersConfig;
import dev.isxander.yacl3.api.ConfigCategory;
import dev.isxander.yacl3.api.Option;
import dev.isxander.yacl3.api.OptionDescription;
import dev.isxander.yacl3.api.OptionGroup;
import de.hysky.skyblocker.skyblock.slayers.hud.SlayerHudConfigScreen;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.FloatFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerFieldControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;

public class SlayersCategory {
Expand Down Expand Up @@ -51,6 +50,47 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.slayers.displayBossbar = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.bossSpawnAlert"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.bossSpawnAlert.@Tooltip[0]")))
.binding(defaults.slayers.bossSpawnAlert,
() -> config.slayers.bossSpawnAlert,
newValue -> config.slayers.bossSpawnAlert = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.miniBossSpawnAlert"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.miniBossSpawnAlert.@Tooltip[0]")))
.binding(defaults.slayers.miniBossSpawnAlert,
() -> config.slayers.miniBossSpawnAlert,
newValue -> config.slayers.miniBossSpawnAlert = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.slainTime"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.slainTime.@Tooltip[0]")))
.binding(defaults.slayers.slainTime,
() -> config.slayers.slainTime,
newValue -> config.slayers.slainTime = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.enableHud"))
.description(OptionDescription.of(
Text.translatable("skyblocker.config.slayer.enableHud.@Tooltip[0]")))
.binding(defaults.slayers.slayerHud.enableHud,
() -> config.slayers.slayerHud.enableHud,
newValue -> config.slayers.slayerHud.enableHud = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(ButtonOption.createBuilder()
.name(Text.translatable("skyblocker.config.slayer.slayerHud"))
.text(Text.translatable("text.skyblocker.open"))
.action((screen, opt) -> MinecraftClient.getInstance().setScreen(new SlayerHudConfigScreen(screen)))
.build())

//Enderman Slayer
.group(OptionGroup.createBuilder()
Expand All @@ -77,6 +117,13 @@ public static ConfigCategory create(SkyblockerConfig defaults, SkyblockerConfig
newValue -> config.slayers.endermanSlayer.highlightNukekubiHeads = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.option(Option.<Boolean>createBuilder()
.name(Text.translatable("skyblocker.config.slayer.endermanSlayer.lazerTimer"))
.binding(defaults.slayers.endermanSlayer.lazerTimer,
() -> config.slayers.endermanSlayer.lazerTimer,
newValue -> config.slayers.endermanSlayer.lazerTimer = newValue)
.controller(ConfigUtils::createBooleanController)
.build())
.build())

//Vampire Slayer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public static class TheEnd {
@SerialEntry
public boolean waypoint = true;

@SerialEntry
public boolean muteEndermanSounds = false;

@SerialEntry
public int x = 10;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ public String toString() {
}
}

@SerialEntry
public boolean bossSpawnAlert = true;

@SerialEntry
public boolean miniBossSpawnAlert = true;

@SerialEntry
public boolean slainTime = true;

@SerialEntry
public SlayerHud slayerHud = new SlayerHud();

@SerialEntry
public EndermanSlayer endermanSlayer = new EndermanSlayer();

Expand All @@ -31,6 +43,17 @@ public String toString() {
@SerialEntry
public BlazeSlayer blazeSlayer = new BlazeSlayer();

public static class SlayerHud {
@SerialEntry
public boolean enableHud = true;

@SerialEntry
public int x;

@SerialEntry
public int y;
}

public static class EndermanSlayer {
@SerialEntry
public boolean enableYangGlyphsNotification = true;
Expand All @@ -40,6 +63,9 @@ public static class EndermanSlayer {

@SerialEntry
public boolean highlightNukekubiHeads = true;

@SerialEntry
public boolean lazerTimer = true;
}

public static class VampireSlayer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
import de.hysky.skyblocker.skyblock.FishingHelper;
import de.hysky.skyblocker.skyblock.chocolatefactory.EggFinder;
import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager;
import de.hysky.skyblocker.skyblock.crimson.slayer.FirePillarAnnouncer;
import de.hysky.skyblocker.skyblock.dungeon.DungeonScore;
import de.hysky.skyblocker.skyblock.dungeon.secrets.DungeonManager;
import de.hysky.skyblocker.skyblock.dwarven.WishingCompassSolver;
import de.hysky.skyblocker.skyblock.dwarven.CrystalsChestHighlighter;
import de.hysky.skyblocker.skyblock.end.EnderNodes;
import de.hysky.skyblocker.skyblock.end.TheEnd;
import de.hysky.skyblocker.skyblock.slayers.SlayerEntitiesGlow;
import de.hysky.skyblocker.skyblock.slayers.boss.demonlord.FirePillarAnnouncer;
import de.hysky.skyblocker.skyblock.slayers.features.SlayerEntitiesGlow;
import de.hysky.skyblocker.skyblock.waypoint.MythologicalRitual;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.client.network.ClientPlayNetworkHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import de.hysky.skyblocker.skyblock.crimson.dojo.DojoManager;
import de.hysky.skyblocker.skyblock.dungeon.device.SimonSays;
import de.hysky.skyblocker.skyblock.dwarven.CrystalsChestHighlighter;
import de.hysky.skyblocker.skyblock.end.BeaconHighlighter;
import de.hysky.skyblocker.utils.SlayerUtils;
import de.hysky.skyblocker.skyblock.slayers.SlayerManager;
import de.hysky.skyblocker.skyblock.slayers.boss.voidgloom.BeaconHighlighter;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
Expand All @@ -31,7 +31,7 @@ public class ClientWorldMixin {
DojoManager.onBlockUpdate(pos.toImmutable(), state);
} else if (Utils.isInCrystalHollows()) {
CrystalsChestHighlighter.onBlockUpdate(pos.toImmutable(), state);
} else if (Utils.isInTheEnd() && SlayerUtils.isInSlayer()) {
} else if (Utils.isInTheEnd() && SlayerManager.isBossSpawned()) {
BeaconHighlighter.beaconPositions.remove(pos);

if (state.isOf(Blocks.BEACON)) BeaconHighlighter.beaconPositions.add(pos.toImmutable());
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixins/EntityMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,84 @@

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.debug.Debug;
import de.hysky.skyblocker.skyblock.slayers.SlayerManager;
import de.hysky.skyblocker.skyblock.slayers.boss.voidgloom.LazerTimer;
import de.hysky.skyblocker.utils.Utils;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.mob.EndermanEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.UUID;

@Mixin(Entity.class)
public abstract class EntityMixin {
@Shadow
@Final
private EntityType<?> type;

@Shadow
public abstract UUID getUuid();

@Shadow
public abstract EntityType<?> getType();

@Shadow
public abstract BlockPos getBlockPos();

@Shadow
public abstract Vec3d getPos();

@Shadow
public abstract @Nullable Entity getVehicle();

@Shadow
public abstract boolean isInvisible();

@ModifyExpressionValue(method = "isInvisibleTo", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;isSpectator()Z"))
public boolean skyblocker$showInvisibleArmorStands(boolean isSpectator, PlayerEntity player) {
return isSpectator || (isInvisible() && Utils.isOnHypixel() && Debug.debugEnabled() && SkyblockerConfigManager.get().debug.showInvisibleArmorStands && type.equals(EntityType.ARMOR_STAND));
}

@Inject(method = "startRiding(Lnet/minecraft/entity/Entity;Z)Z", at = @At("RETURN"))
private void onStartRiding(Entity entity, boolean force, CallbackInfoReturnable<Boolean> cir) {
if (cir.getReturnValue()) {
if (SkyblockerConfigManager.get().slayers.endermanSlayer.lazerTimer && SlayerManager.isBossSpawned() && this.getType() == EntityType.ENDERMAN && entity.getType() == EntityType.ARMOR_STAND) {
Entity slayer = SlayerManager.getSlayerEntity(EndermanEntity.class);
if (slayer != null) {
if (slayer.getUuid().equals(getUuid()) && !LazerTimer.isRiding()) {
LazerTimer.bossUUID = getUuid();
LazerTimer.bossLocation = getPos();
LazerTimer.resetTimer();
LazerTimer.setRiding(true);
}
}
}
}
}

@Inject(method = "tick", at = @At("TAIL"))
private void onTick(CallbackInfo ci) {
if (this.getType() == EntityType.ENDERMAN) {
if (LazerTimer.isRiding() && LazerTimer.bossUUID.equals(getUuid()) && getVehicle() == null) {
if (LazerTimer.remainingTime > 5.0) return;
LazerTimer.bossUUID = null;
LazerTimer.bossLocation = null;
LazerTimer.setRiding(false);
}
}
}
}
57 changes: 57 additions & 0 deletions src/main/java/de/hysky/skyblocker/mixins/SoundSystemMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package de.hysky.skyblocker.mixins;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.skyblock.slayers.SlayerManager;
import de.hysky.skyblocker.utils.LocationUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.title.Title;
import de.hysky.skyblocker.utils.render.title.TitleContainer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.sound.SoundInstance;
import net.minecraft.client.sound.SoundSystem;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(SoundSystem.class)
public class SoundSystemMixin {

@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("TAIL"))
private void onPlayTail(SoundInstance soundInstance, CallbackInfo ci) {
if (SkyblockerConfigManager.get().slayers.miniBossSpawnAlert && Utils.isOnSkyblock() && soundInstance.getSound() != null && soundInstance.getId().equals(Identifier.ofVanilla("entity.generic.explode"))) {
if (SlayerManager.isInSlayer() && SlayerManager.getSlayerQuest().isLfMinis() && soundInstance.getPitch() == 9 / 7f && soundInstance.getVolume() == 0.6f) {
final Title title = new Title(Text.literal(I18n.translate("skyblocker.slayer.miniBossSpawnAlert")).formatted(Formatting.RED));
//Checks if MiniBoss is within a radius of the client's location
if (LocationUtils.isWithinRadius(BlockPos.ofFloored(soundInstance.getX(), soundInstance.getY(), soundInstance.getZ()), 15)) {
if (!TitleContainer.containsTitle(title.getText())) {
TitleContainer.addTitle(title, 20);
MinecraftClient.getInstance().player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING.value(), 0.5f, 0.1f);
}
}
}
}
}

@Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At("HEAD"), cancellable = true)
private void onPlayHead(SoundInstance soundInstance, CallbackInfo ci) {
if (Utils.isInTheEnd() && SkyblockerConfigManager.get().otherLocations.end.muteEndermanSounds) {
// Check if the sound identifier matches any Enderman sound identifiers
if (soundInstance.getId().equals(SoundEvents.ENTITY_ENDERMAN_AMBIENT.id()) ||
soundInstance.getId().equals(SoundEvents.ENTITY_ENDERMAN_DEATH.id()) ||
soundInstance.getId().equals(SoundEvents.ENTITY_ENDERMAN_HURT.id()) ||
soundInstance.getId().equals(SoundEvents.ENTITY_ENDERMAN_SCREAM.id()) ||
soundInstance.getId().equals(SoundEvents.ENTITY_ENDERMAN_STARE.id())) {
// Cancel the playback of Enderman sounds
ci.cancel();
}
}
}
}
Loading