Skip to content

Commit

Permalink
make hytils mixins follow standard practices (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed Jun 19, 2024
1 parent d13aed3 commit 87b4142
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@

@Mixin(BossStatus.class)
public abstract class BossStatusMixin_HideBossbar {

@Inject(method = "setBossStatus", at = @At("HEAD"), cancellable = true)
private static void cancelBossStatus(IBossDisplayData displayData, boolean hasColorModifierIn, CallbackInfo ci) {
private static void hytils$cancelBossStatus(IBossDisplayData displayData, boolean hasColorModifierIn, CallbackInfo ci) {
if (displayData == null) return;
if (HytilsConfig.lobbyBossbar && !LocrawUtil.INSTANCE.isInGame() || HytilsConfig.gameAdBossbar && displayData.getDisplayName().getFormattedText().matches(HytilsReborn.INSTANCE.getLanguageHandler().getCurrent().gameBossbarAdvertisementRegex.pattern()))
ci.cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
@Pseudo
@Mixin(targets = "me.semx11.autotip.command.impl.CommandLimbo", remap = false)
public class CommandLimboMixin_FixCommand {

@Dynamic("AutoTip")
@ModifyConstant(method = "onCommand", constant = @Constant(stringValue = "/achat \u00a7c"))
private String fixAutotipCommand(String value) {
private String hytils$fixAutotipCommand(String value) {
return "§";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
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(EntityLivingBase.class)
public class EntityLivingBaseMixin_MiningFatigue {
private final EntityLivingBase $this = (EntityLivingBase) (Object) this;

@Unique
private final EntityLivingBase hytils$this = (EntityLivingBase) (Object) this;

@Inject(method = "addPotionEffect", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/EntityLivingBase;onNewPotionEffect(Lnet/minecraft/potion/PotionEffect;)V"))
private void onPotionEffect(PotionEffect potioneffectIn, CallbackInfo ci) {
if (HytilsConfig.notifyMiningFatigue && potioneffectIn.getPotionID() == Potion.digSlowdown.getId() && LocrawUtil.INSTANCE.getLocrawInfo() != null && ($this instanceof EntityPlayerSP) && (!HytilsConfig.disableNotifyMiningFatigueSkyblock || !(LocrawUtil.INSTANCE.getLocrawInfo().getGameType() == LocrawInfo.GameType.SKYBLOCK))) {
private void hytils$onPotionEffect(PotionEffect potioneffectIn, CallbackInfo ci) {
if (HytilsConfig.notifyMiningFatigue && potioneffectIn.getPotionID() == Potion.digSlowdown.getId() && LocrawUtil.INSTANCE.getLocrawInfo() != null && (hytils$this instanceof EntityPlayerSP) && (!HytilsConfig.disableNotifyMiningFatigueSkyblock || !(LocrawUtil.INSTANCE.getLocrawInfo().getGameType() == LocrawInfo.GameType.SKYBLOCK))) {
Notifications.INSTANCE.send("Hytils Reborn", "You have mining fatigue!");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Mixin(EntityPlayerSP.class)
public class EntityPlayerSPMixin_MessageHandling {
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void handleSentMessages(String message, CallbackInfo ci) {
private void hytils$handleSentMessages(String message, CallbackInfo ci) {
if (HytilsReborn.INSTANCE.getChatHandler().handleSentMessage(message) == null) ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class GuiChatMixin_PlayAutocomplete extends GuiScreen {
protected GuiTextField inputField;

@Redirect(method = "autocompletePlayerNames", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;printChatMessageWithOptionalDeletion(Lnet/minecraft/util/IChatComponent;I)V"))
private void redirectAutocomplete(GuiNewChat instance, IChatComponent chatComponent, int chatLineId) {
private void hytils$redirectAutocomplete(GuiNewChat instance, IChatComponent chatComponent, int chatLineId) {
if (!this.inputField.getText().startsWith("/play ")) {
instance.printChatMessageWithOptionalDeletion(chatComponent, 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

@Mixin(GuiIngame.class)
public interface GuiIngameAccessor {

@Accessor("displayedTitle")
void setDisplayedTitle(String title);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Mixin(value = GuiIngameForge.class, remap = false, priority = 990)
public class GuiIngameForgeMixin_HideActionbar {
@Inject(method = "renderRecordOverlay", at = @At("HEAD"), cancellable = true)
private void cancelActionBar(int width, int height, float partialTicks, CallbackInfo ci) {
private void hytils$cancelActionBar(int width, int height, float partialTicks, CallbackInfo ci) {
if (HypixelUtils.INSTANCE.isHypixel() && LocrawUtil.INSTANCE.getLocrawInfo() != null && ((HytilsConfig.hideHousingActionBar && LocrawUtil.INSTANCE.getLocrawInfo().getGameType() == LocrawInfo.GameType.HOUSING) || (HytilsConfig.hideDropperActionBar && LocrawUtil.INSTANCE.getLocrawInfo().getGameMode().equals("DROPPER"))))
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Mixin(value = GuiIngameForge.class, remap = false)
public class GuiIngameForgeMixin_HideHotbar {
@Inject(method = "renderHealth", at = @At("HEAD"), cancellable = true)
public void cancelHealthbar(int width, int height, CallbackInfo ci) {
public void hytils$cancelHealthbar(int width, int height, CallbackInfo ci) {
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) {
if (!LocrawUtil.INSTANCE.isInGame()) {
Expand Down Expand Up @@ -80,7 +80,7 @@ public void cancelHealthbar(int width, int height, CallbackInfo ci) {
}

@Inject(method = "renderFood", at = @At("HEAD"), cancellable = true)
public void cancelFood(int width, int height, CallbackInfo ci) {
public void hytils$cancelFood(int width, int height, CallbackInfo ci) {
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) {
if (!LocrawUtil.INSTANCE.isInGame()) {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void cancelFood(int width, int height, CallbackInfo ci) {
}

@Inject(method = "renderArmor", at = @At("HEAD"), cancellable = true)
public void cancelArmor(int width, int height, CallbackInfo ci) {
public void hytils$cancelArmor(int width, int height, CallbackInfo ci) {
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) {
if (!LocrawUtil.INSTANCE.isInGame()) {
Expand Down Expand Up @@ -173,7 +173,7 @@ public void cancelArmor(int width, int height, CallbackInfo ci) {
}

@Inject(method = "renderAir", at = @At("HEAD"), cancellable = true)
public void cancelAir(int width, int height, CallbackInfo ci) {
public void hytils$cancelAir(int width, int height, CallbackInfo ci) {
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HytilsConfig.hideHudElements && HypixelUtils.INSTANCE.isHypixel()) {
if (!LocrawUtil.INSTANCE.isInGame()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public GuiIngameForgeMixin_TitleEvent(Minecraft mcIn) {
}

@Redirect(method = "renderHealth", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/storage/WorldInfo;isHardcoreModeEnabled()Z", remap = true))
private boolean isHardcore(WorldInfo instance) {
private boolean hytils$isHardcore(WorldInfo instance) {
return instance.isHardcoreModeEnabled() || HytilsReborn.INSTANCE.getHardcoreStatus().shouldChangeStyle();
}

@Inject(method = "renderTitle", at = @At("HEAD"), cancellable = true)
private void postTitleEvent(int l, int age, float opacity, CallbackInfo ci) {
private void hytils$postTitleEvent(int l, int age, float opacity, CallbackInfo ci) {
if (HypixelUtils.INSTANCE.isHypixel()) {
TitleEvent event = new TitleEvent(displayedTitle, displayedSubTitle);
MinecraftForge.EVENT_BUS.post(event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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;
Expand All @@ -46,16 +47,17 @@ public abstract class GuiNewChatMixin_LocrawHider {
@Shadow public abstract void deleteChatLine(int id);

@Inject(method = "printChatMessageWithOptionalDeletion", at = @At("HEAD"), cancellable = true)
private void handlePrintChatMessage(IChatComponent chatComponent, int chatLineId, CallbackInfo ci) {
handleHytilsMessage(chatComponent, chatLineId, mc.ingameGUI.getUpdateCounter(), false, ci);
private void hytils$handlePrintChatMessage(IChatComponent chatComponent, int chatLineId, CallbackInfo ci) {
hytils$handleHytilsMessage(chatComponent, chatLineId, mc.ingameGUI.getUpdateCounter(), false, ci);
}

@Inject(method = "setChatLine", at = @At("HEAD"), cancellable = true)
private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
handleHytilsMessage(chatComponent, chatLineId, updateCounter, displayOnly, ci);
private void hytils$handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
hytils$handleHytilsMessage(chatComponent, chatLineId, updateCounter, displayOnly, ci);
}

private void handleHytilsMessage(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
@Unique
private void hytils$handleHytilsMessage(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
if (HytilsConfig.hideLocraw && HypixelUtils.INSTANCE.isHypixel() && chatComponent.getUnformattedTextForChat().startsWith("{") && chatComponent.getUnformattedTextForChat().endsWith("}")) {
percentComplete = 1.0F;
if (chatLineId != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@Mixin(GuiPlayerTabOverlay.class)
public class GuiPlayerTabOverlayMixin_HideNPCs {
@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/NetHandlerPlayClient;getPlayerInfoMap()Ljava/util/Collection;"))
private Collection<NetworkPlayerInfo> hideNPCs(NetHandlerPlayClient instance) {
private Collection<NetworkPlayerInfo> hytils$hideNPCs(NetHandlerPlayClient instance) {
return NPCHandler.hideTabNpcs(instance.getPlayerInfoMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
@Mixin(value = GuiPlayerTabOverlay.class, priority = 990)
public class GuiPlayerTabOverlayMixin_HidePing {
@Inject(method = "drawPing", at = @At("HEAD"), cancellable = true)
private void checkPlayer(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn, CallbackInfo ci) {
private void hytils$checkPlayer(int p_175245_1_, int p_175245_2_, int p_175245_3_, NetworkPlayerInfo networkPlayerInfoIn, CallbackInfo ci) {
if (TabChanger.hidePing(networkPlayerInfoIn)) ci.cancel();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@

@Mixin(GuiPlayerTabOverlay.class)
public class GuiPlayerTabOverlayMixin_RemoveAds {

@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;listFormattedStringToWidth(Ljava/lang/String;I)Ljava/util/List;", ordinal = 1))
private List<String> hideAdvertisementsInTabFooter(FontRenderer instance, String formattedFooter, int wrapWidth) {
private List<String> hytils$hideAdvertisementsInTabFooter(FontRenderer instance, String formattedFooter, int wrapWidth) {
return TabChanger.modifyFooter(instance, formattedFooter, wrapWidth);

}

@Redirect(method = "renderPlayerlist", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;listFormattedStringToWidth(Ljava/lang/String;I)Ljava/util/List;", ordinal = 0))
private List<String> hideAdvertisementsInTabHeader(FontRenderer instance, String formattedHeader, int wrapWidth) {
private List<String> hytils$hideAdvertisementsInTabHeader(FontRenderer instance, String formattedHeader, int wrapWidth) {
return TabChanger.modifyHeader(instance, formattedHeader, wrapWidth);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
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;
Expand All @@ -39,13 +40,14 @@ public abstract class LayerArmorBaseMixin_HideIngameArmour {
public abstract ItemStack getCurrentArmor(EntityLivingBase entitylivingbaseIn, int armorSlot);

@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;getArmorModel(I)Lnet/minecraft/client/model/ModelBase;"), cancellable = true)
private void cancelArmor(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float partialTicks, float p_177182_5_, float p_177182_6_, float p_177182_7_, float scale, int armorSlot, CallbackInfo ci) {
if (shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot)) && !entitylivingbaseIn.isInvisible()) {
private void hytils$cancelArmor(EntityLivingBase entitylivingbaseIn, float p_177182_2_, float p_177182_3_, float partialTicks, float p_177182_5_, float p_177182_6_, float p_177182_7_, float scale, int armorSlot, CallbackInfo ci) {
if (hytils$shouldCancel(getCurrentArmor(entitylivingbaseIn, armorSlot)) && !entitylivingbaseIn.isInvisible()) {
ci.cancel();
}
}

private static boolean shouldCancel(ItemStack itemStack) {
@Unique
private static boolean hytils$shouldCancel(ItemStack itemStack) {
if (!HytilsConfig.hideArmor || itemStack == null || !HypixelUtils.INSTANCE.isHypixel()) return false;
final LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
final Item item = itemStack.getItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class MinecraftMixin_LeftClickInteract {
public EntityPlayerSP thePlayer;

@Redirect(method = "clickMouse", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;clickBlock(Lnet/minecraft/util/BlockPos;Lnet/minecraft/util/EnumFacing;)Z"))
private boolean captureClickBlock(PlayerControllerMP instance, BlockPos itemstack, EnumFacing block1) {
private boolean hytils$captureClickBlock(PlayerControllerMP instance, BlockPos itemstack, EnumFacing block1) {
ForgeEventFactory.onPlayerInteract(thePlayer, PlayerInteractEvent.Action.LEFT_CLICK_BLOCK, theWorld, itemstack, objectMouseOver.sideHit, objectMouseOver.hitVec);
return instance.clickBlock(itemstack, block1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@

@Mixin(Minecraft.class)
public class MinecraftMixin_LimboLimiter {

@Inject(method = "getLimitFramerate", at = @At("HEAD"), cancellable = true)
private void limitFramerate(CallbackInfoReturnable<Integer> cir) {
private void hytils$limitFramerate(CallbackInfoReturnable<Integer> cir) {
if (LimboLimiter.shouldLimitFramerate()) cir.setReturnValue(HytilsConfig.limboFPS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
@Mixin(RenderEntityItem.class)
public class RenderEntityItemMixin_UHCOverlay {
@Inject(method = "func_177077_a(Lnet/minecraft/entity/item/EntityItem;DDDFLnet/minecraft/client/resources/model/IBakedModel;)I", at = @At(("TAIL")))
public void scaleSpecialItems(EntityItem entity, double f4, double f5, double flag, float i, IBakedModel f, CallbackInfoReturnable<Integer> cir) {
public void hytils$scaleSpecialItems(EntityItem entity, double f4, double f5, double flag, float i, IBakedModel f, CallbackInfoReturnable<Integer> cir) {
Item item = entity.getEntityItem().getItem();
LocrawInfo locraw = LocrawUtil.INSTANCE.getLocrawInfo();
if (HypixelUtils.INSTANCE.isHypixel() && locraw != null && (locraw.getGameType() == LocrawInfo.GameType.UHC_CHAMPIONS || locraw.getGameType() == LocrawInfo.GameType.SPEED_UHC) && HytilsConfig.uhcOverlay) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
@Mixin(BlockModelShapes.class)
public class BlockModelShapesMixin {
@Inject(method = "getTexture", at = @At("HEAD"), cancellable = true)
private void addBedTextures(IBlockState state, CallbackInfoReturnable<TextureAtlasSprite> cir) {
private void hytils$addBedTextures(IBlockState state, CallbackInfoReturnable<TextureAtlasSprite> cir) {
IBakedModel model = BedModelHook.getBedModel(state, Minecraft.getMinecraft().thePlayer.getPosition(), null);
if (model != null) {
cir.setReturnValue(model.getParticleTexture());
}
}

@Inject(method = "reloadModels", at = @At("HEAD"))
private void reloadModels(CallbackInfo ci) {
private void hytils$reloadModels(CallbackInfo ci) {
BedModelHook.reloadModels();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Mixin(BlockRendererDispatcher.class)
public class BlockRendererDispatcherMixin {
@Inject(method = "getModelFromBlockState", at = @At("RETURN"), cancellable = true)
private void addBedModels(IBlockState state, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<IBakedModel> cir) {
private void hytils$addBedModels(IBlockState state, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<IBakedModel> cir) {
IBakedModel model = BedModelHook.getBedModel(state, pos, cir.getReturnValue());
if (model != null) {
cir.setReturnValue(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class ModelLoaderMixin {
private Set<ResourceLocation> textures;

@Inject(method = "setupModelRegistry", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/texture/TextureMap;loadSprites(Lnet/minecraft/client/resources/IResourceManager;Lnet/minecraft/client/renderer/texture/IIconCreator;)V"), remap = true)
private void getVariantsTextureLocations(CallbackInfoReturnable<Set<ResourceLocation>> cir) {
private void hytils$getVariantsTextureLocations(CallbackInfoReturnable<Set<ResourceLocation>> cir) {
for (String color : BedLocationHandler.COLORS_REVERSE.values()) {
textures.add(new ResourceLocation(BedModelHook.COLORED_BED + color));
}
Expand Down
Loading

0 comments on commit 87b4142

Please sign in to comment.