-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
969fa4f
commit 8dc3119
Showing
8 changed files
with
82 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 39 additions & 8 deletions
47
src/main/java/de/hysky/skyblocker/mixin/DataTrackerMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,50 @@ | ||
package de.hysky.skyblocker.mixin; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import de.hysky.skyblocker.config.SkyblockerConfigManager; | ||
import de.hysky.skyblocker.mixin.accessor.EndermanEntityAccessor; | ||
import de.hysky.skyblocker.skyblock.entity.MobGlow; | ||
import de.hysky.skyblocker.utils.Utils; | ||
import net.minecraft.block.BlockState; | ||
import net.minecraft.block.Blocks; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.data.DataTracker; | ||
import net.minecraft.sound.SoundEvents; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
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 org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import de.hysky.skyblocker.utils.Utils; | ||
import net.minecraft.entity.data.DataTracker; | ||
import java.util.Optional; | ||
|
||
@Mixin(DataTracker.class) | ||
public class DataTrackerMixin { | ||
public abstract class DataTrackerMixin { | ||
@Shadow | ||
@Final | ||
private Entity trackedEntity; | ||
|
||
@SuppressWarnings("ConstantValue") | ||
@Inject(method = "writeUpdatedEntries", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/data/DataTracker;copyToFrom(Lnet/minecraft/entity/data/DataTracker$Entry;Lnet/minecraft/entity/data/DataTracker$SerializedEntry;)V")) | ||
private <T> void skyblocker$onWriteUpdatedEntries(CallbackInfo ci, @Local DataTracker.Entry<T> entry, @Local DataTracker.SerializedEntry<T> serializedEntry) { | ||
if (Utils.isInTheEnd() && SkyblockerConfigManager.get().slayer.endermanSlayer.enableYangGlyphsNotification && entry.getData() == EndermanEntityAccessor.getCARRIED_BLOCK() && entry.get() instanceof Optional<?> value && value.isPresent() && value.get() instanceof BlockState state && state.isOf(Blocks.BEACON) && ((Optional<?>) serializedEntry.value()).isEmpty()) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
if (MobGlow.getArmorStands(trackedEntity).stream().anyMatch(armorStand -> armorStand.getName().getString().contains(client.getSession().getUsername()))) { | ||
client.inGameHud.setTitleTicks(5, 20, 10); | ||
client.inGameHud.setTitle(Text.literal("Yang Glyph!").formatted(Formatting.RED)); | ||
client.player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING.value(), 100f, 0.1f); | ||
} | ||
} | ||
} | ||
|
||
@Inject(method = "copyToFrom", at = @At(value = "NEW", target = "Ljava/lang/IllegalStateException;", shift = At.Shift.BEFORE), cancellable = true) | ||
public void skyblocker$ignoreInvalidDataExceptions(CallbackInfo ci) { | ||
//These exceptions cause annoying small lag spikes for some reason | ||
if (Utils.isOnHypixel()) ci.cancel(); | ||
} | ||
@SuppressWarnings({"MixinAnnotationTarget", "UnresolvedMixinReference"}) | ||
@Inject(method = "copyToFrom", at = @At(value = "NEW", target = "Ljava/lang/IllegalStateException;"), cancellable = true) | ||
public void skyblocker$ignoreInvalidDataExceptions(CallbackInfo ci) { | ||
//These exceptions cause annoying small lag spikes for some reason | ||
if (Utils.isOnHypixel()) ci.cancel(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/de/hysky/skyblocker/mixin/accessor/EndermanEntityAccessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.hysky.skyblocker.mixin.accessor; | ||
|
||
import net.minecraft.block.BlockState; | ||
import net.minecraft.entity.data.TrackedData; | ||
import net.minecraft.entity.mob.EndermanEntity; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.gen.Accessor; | ||
|
||
import java.util.Optional; | ||
|
||
@Mixin(EndermanEntity.class) | ||
public interface EndermanEntityAccessor { | ||
@Accessor | ||
static TrackedData<Optional<BlockState>> getCARRIED_BLOCK() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters