aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorRime <81419447+Emirlol@users.noreply.github.com>2024-05-15 01:21:00 +0300
committerRime <81419447+Emirlol@users.noreply.github.com>2024-05-23 13:31:48 +0300
commit5b7c40ea4cf6495dad5c935eb566f851d9062e57 (patch)
treeac13de1a52fe91624978717d1facadcc251fb578 /src/main
parent5ea7ccf01559a12f79bb06f4cf8f762895620038 (diff)
downloadSkyblocker-5b7c40ea4cf6495dad5c935eb566f851d9062e57.tar.gz
Skyblocker-5b7c40ea4cf6495dad5c935eb566f851d9062e57.tar.bz2
Skyblocker-5b7c40ea4cf6495dad5c935eb566f851d9062e57.zip
Refactor EggFinder for CompactDamage compatibility
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java183
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/CompactDamage.java1
-rw-r--r--src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java6
3 files changed, 96 insertions, 94 deletions
diff --git a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java
index 9ff1fc84..3ca68df3 100644
--- a/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java
+++ b/src/main/java/de/hysky/skyblocker/mixins/ClientPlayNetworkHandlerMixin.java
@@ -35,98 +35,95 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ClientPlayNetworkHandler.class)
public abstract class ClientPlayNetworkHandlerMixin {
- @Shadow
- private ClientWorld world;
-
- @Shadow
- @Final
- private static Logger LOGGER;
-
- @Inject(method = "onBlockUpdate", at = @At("RETURN"))
- private void skyblocker$onBlockUpdate(BlockUpdateS2CPacket packet, CallbackInfo ci) {
- if (Utils.isInTheEnd() && SlayerUtils.isInSlayer()) {
- BeaconHighlighter.beaconPositions.remove(packet.getPos());
- if (packet.getState().isOf(Blocks.BEACON)) {
- BeaconHighlighter.beaconPositions.add(packet.getPos());
- }
- }
- }
-
- @Inject(method = "method_37472", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V"))
- private void skyblocker$onItemDestroy(int entityId, CallbackInfo ci) {
- if (world.getEntityById(entityId) instanceof ItemEntity itemEntity) {
- DungeonManager.onItemPickup(itemEntity);
- }
- }
-
- @ModifyVariable(method = "onItemPickupAnimation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V", ordinal = 0))
- private ItemEntity skyblocker$onItemPickup(ItemEntity itemEntity) {
- DungeonManager.onItemPickup(itemEntity);
- return itemEntity;
- }
-
- @WrapWithCondition(method = "onEntityPassengersSet", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false))
- private boolean skyblocker$cancelEntityPassengersWarning(Logger instance, String msg) {
- return !Utils.isOnHypixel();
- }
-
- @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
- private boolean skyblocker$cancelPlayerListWarning(Logger instance, String format, Object arg1, Object arg2) {
- return !Utils.isOnHypixel();
- }
-
- @Inject(method = "onPlaySound", at = @At("RETURN"))
- private void skyblocker$onPlaySound(PlaySoundS2CPacket packet, CallbackInfo ci) {
- FishingHelper.onSound(packet);
- }
-
- @WrapWithCondition(method = "warnOnUnknownPayload", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
- private boolean skyblocker$dropBadlionPacketWarnings(Logger instance, String message, Object identifier) {
- return !(Utils.isOnHypixel() && ((Identifier) identifier).getNamespace().equals("badlion"));
- }
-
- @WrapWithCondition(method = { "onScoreboardScoreUpdate", "onScoreboardScoreReset" }, at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
- private boolean skyblocker$cancelUnknownScoreboardObjectiveWarnings(Logger instance, String message, Object objectiveName) {
- return !Utils.isOnHypixel();
- }
-
- @WrapWithCondition(method = "onTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
- private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) {
- return !Utils.isOnHypixel();
- }
-
- @Inject(method = "onParticle", at = @At("RETURN"))
- private void skyblocker$onParticle(ParticleS2CPacket packet, CallbackInfo ci) {
- MythologicalRitual.onParticle(packet);
- EnderNodes.onParticle(packet);
- }
-
- @ModifyExpressionValue(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityStatusS2CPacket;getEntity(Lnet/minecraft/world/World;)Lnet/minecraft/entity/Entity;"))
- private Entity skyblocker$onEntityDeath(Entity entity, @Local(argsOnly = true) EntityStatusS2CPacket packet) {
- if (packet.getStatus() == EntityStatuses.PLAY_DEATH_SOUND_OR_ADD_PROJECTILE_HIT_PARTICLES) {
- DungeonScore.handleEntityDeath(entity);
- TheEnd.onEntityDeath(entity);
- }
- return entity;
- }
-
- @Inject(method = "onEntityTrackerUpdate", at = @At("TAIL"))
- private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
- if (!SkyblockerConfigManager.get().uiAndVisuals.compactDamage.enabled || !(entity instanceof ArmorStandEntity armorStandEntity)) return;
- try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers
+ @Shadow
+ private ClientWorld world;
+
+ @Shadow
+ @Final
+ private static Logger LOGGER;
+
+ @Inject(method = "onBlockUpdate", at = @At("RETURN"))
+ private void skyblocker$onBlockUpdate(BlockUpdateS2CPacket packet, CallbackInfo ci) {
+ if (Utils.isInTheEnd() && SlayerUtils.isInSlayer()) {
+ BeaconHighlighter.beaconPositions.remove(packet.getPos());
+ if (packet.getState().isOf(Blocks.BEACON)) {
+ BeaconHighlighter.beaconPositions.add(packet.getPos());
+ }
+ }
+ }
+
+ @Inject(method = "method_37472", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V"))
+ private void skyblocker$onItemDestroy(int entityId, CallbackInfo ci) {
+ if (world.getEntityById(entityId) instanceof ItemEntity itemEntity) {
+ DungeonManager.onItemPickup(itemEntity);
+ }
+ }
+
+ @ModifyVariable(method = "onItemPickupAnimation", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientWorld;removeEntity(ILnet/minecraft/entity/Entity$RemovalReason;)V", ordinal = 0))
+ private ItemEntity skyblocker$onItemPickup(ItemEntity itemEntity) {
+ DungeonManager.onItemPickup(itemEntity);
+ return itemEntity;
+ }
+
+ @WrapWithCondition(method = "onEntityPassengersSet", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;)V", remap = false))
+ private boolean skyblocker$cancelEntityPassengersWarning(Logger instance, String msg) {
+ return !Utils.isOnHypixel();
+ }
+
+ @WrapWithCondition(method = "onPlayerList", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V", remap = false))
+ private boolean skyblocker$cancelPlayerListWarning(Logger instance, String format, Object arg1, Object arg2) {
+ return !Utils.isOnHypixel();
+ }
+
+ @Inject(method = "onPlaySound", at = @At("RETURN"))
+ private void skyblocker$onPlaySound(PlaySoundS2CPacket packet, CallbackInfo ci) {
+ FishingHelper.onSound(packet);
+ }
+
+ @WrapWithCondition(method = "warnOnUnknownPayload", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
+ private boolean skyblocker$dropBadlionPacketWarnings(Logger instance, String message, Object identifier) {
+ return !(Utils.isOnHypixel() && ((Identifier) identifier).getNamespace().equals("badlion"));
+ }
+
+ @WrapWithCondition(method = {"onScoreboardScoreUpdate", "onScoreboardScoreReset"}, at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;)V", remap = false))
+ private boolean skyblocker$cancelUnknownScoreboardObjectiveWarnings(Logger instance, String message, Object objectiveName) {
+ return !Utils.isOnHypixel();
+ }
+
+ @WrapWithCondition(method = "onTeam", at = @At(value = "INVOKE", target = "Lorg/slf4j/Logger;warn(Ljava/lang/String;[Ljava/lang/Object;)V", remap = false))
+ private boolean skyblocker$cancelTeamWarning(Logger instance, String format, Object... arg) {
+ return !Utils.isOnHypixel();
+ }
+
+ @Inject(method = "onParticle", at = @At("RETURN"))
+ private void skyblocker$onParticle(ParticleS2CPacket packet, CallbackInfo ci) {
+ MythologicalRitual.onParticle(packet);
+ EnderNodes.onParticle(packet);
+ }
+
+ @ModifyExpressionValue(method = "onEntityStatus", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/packet/s2c/play/EntityStatusS2CPacket;getEntity(Lnet/minecraft/world/World;)Lnet/minecraft/entity/Entity;"))
+ private Entity skyblocker$onEntityDeath(Entity entity, @Local(argsOnly = true) EntityStatusS2CPacket packet) {
+ if (packet.getStatus() == EntityStatuses.PLAY_DEATH_SOUND_OR_ADD_PROJECTILE_HIT_PARTICLES) {
+ DungeonScore.handleEntityDeath(entity);
+ TheEnd.onEntityDeath(entity);
+ }
+ return entity;
+ }
+
+ @Inject(method = "onEntityTrackerUpdate", at = @At("TAIL"))
+ private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
+ if (!(entity instanceof ArmorStandEntity armorStandEntity)) return;
+
+ EggFinder.checkIfEgg(armorStandEntity);
+ try { //Prevent packet handling fails if something goes wrong so that entity trackers still update, just without compact damage numbers
CompactDamage.compactDamage(armorStandEntity);
- } catch (Exception e) {
- LOGGER.error("[Skyblocker Compact Damage] Failed to compact damage number", e);
- }
- }
-
- @Inject(method = "onEntityEquipmentUpdate", at = @At(value = "TAIL"))
- private void skyblocker$onEntityEquip(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
- EggFinder.checkIfEgg(entity);
- }
-
- @Inject(method = "onEntityTrackerUpdate", at = @At(value = "TAIL"))
- private void skyblocker$onEntityTrackerUpdate(EntityTrackerUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
- EggFinder.checkIfEgg(entity);
- }
+ } catch (Exception e) {
+ LOGGER.error("[Skyblocker Compact Damage] Failed to compact damage number", e);
+ }
+ }
+
+ @Inject(method = "onEntityEquipmentUpdate", at = @At(value = "TAIL"))
+ private void skyblocker$onEntityEquip(EntityEquipmentUpdateS2CPacket packet, CallbackInfo ci, @Local Entity entity) {
+ EggFinder.checkIfEgg(entity);
+ }
}
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/CompactDamage.java b/src/main/java/de/hysky/skyblocker/skyblock/CompactDamage.java
index 2837364b..8285a823 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/CompactDamage.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/CompactDamage.java
@@ -19,6 +19,7 @@ public class CompactDamage {
}
public static void compactDamage(ArmorStandEntity entity) {
+ if (!SkyblockerConfigManager.get().uiAndVisuals.compactDamage.enabled) return;
if (!entity.isInvisible() || !entity.hasCustomName() || !entity.isCustomNameVisible()) return;
Text customName = entity.getCustomName();
String customNameStringified = customName.getString();
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java b/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
index 0e887fd2..ee16abd9 100644
--- a/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
+++ b/src/main/java/de/hysky/skyblocker/skyblock/chocolatefactory/EggFinder.java
@@ -39,9 +39,13 @@ public class EggFinder {
}
public static void checkIfEgg(Entity entity) {
+ if (entity instanceof ArmorStandEntity armorStand) checkIfEgg(armorStand);
+ }
+
+ public static void checkIfEgg(ArmorStandEntity armorStand) {
if (!SkyblockerConfigManager.get().helpers.chocolateFactory.enableEggFinder) return;
if (SkyblockTime.skyblockSeason.get() != SkyblockTime.Season.SPRING) return;
- if (!(entity instanceof ArmorStandEntity armorStand) || armorStand.hasCustomName() || !armorStand.isInvisible() || !armorStand.shouldHideBasePlate()) return;
+ if (armorStand.hasCustomName() || !armorStand.isInvisible() || !armorStand.shouldHideBasePlate()) return;
for (ItemStack itemStack : armorStand.getArmorItems()) {
ItemUtils.getHeadTexture(itemStack).ifPresent(texture -> {
for (EggType type : EggType.entries) {