diff options
author | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-08-07 21:38:49 -0400 |
---|---|---|
committer | My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> | 2021-08-07 21:47:08 -0400 |
commit | 5655e975cf02e415e8e1556ea01d8fc445629def (patch) | |
tree | 1f5bbe7f1656f93a2fece6aa39b09c048c6681fe | |
parent | 0541d64050788ecdeed09a553daa0e10fc66f0ac (diff) | |
download | SkytilsMod-5655e975cf02e415e8e1556ea01d8fc445629def.tar.gz SkytilsMod-5655e975cf02e415e8e1556ea01d8fc445629def.tar.bz2 SkytilsMod-5655e975cf02e415e8e1556ea01d8fc445629def.zip |
I started this 4 hours ago
110 files changed, 2607 insertions, 1316 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/entity/MixinAbstractClientPlayer.java b/src/main/java/skytils/skytilsmod/mixins/entity/MixinAbstractClientPlayer.java deleted file mode 100644 index 92c50394..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/entity/MixinAbstractClientPlayer.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.entity; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import kotlin.collections.CollectionsKt; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ResourceLocation; -import net.minecraft.world.World; -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.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.features.impl.misc.SummonSkins; -import skytils.skytilsmod.utils.NumberUtil; -import skytils.skytilsmod.utils.Utils; - -import java.util.List; - -@Mixin(AbstractClientPlayer.class) -public abstract class MixinAbstractClientPlayer extends EntityPlayer { - public MixinAbstractClientPlayer(World worldIn, GameProfile gameProfileIn) { - super(worldIn, gameProfileIn); - } - - @Unique - private static final Minecraft mc = Minecraft.getMinecraft(); - - @Unique - private static final ResourceLocation sychicSkin = new ResourceLocation("skytils:sychicskin.png"); - @Unique - private static final String phoenixSkinObject = "eyJ0aW1lc3RhbXAiOjE1NzU0NzAyNzE3MTUsInByb2ZpbGVJZCI6ImRlNTcxYTEwMmNiODQ4ODA4ZmU3YzlmNDQ5NmVjZGFkIiwicHJvZmlsZU5hbWUiOiJNSEZfTWluZXNraW4iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzM2YTAzODNhNTI3ODAzZDk5YjY2MmFkMThiY2FjNzhjMTE5MjUwZWJiZmIxNDQ3NWI0ZWI0ZDRhNjYyNzk2YjQifX19"; - - private ResourceLocation correctSkin = null; - private String summonType = null; - private Boolean isSummonMob = null; - - @Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("RETURN"), cancellable = true) - private void replaceSkin(CallbackInfoReturnable<ResourceLocation> cir) { - if (isSummonMob()) { - if (Skytils.config.fixSummonSkin) { - if (correctSkin == null) { - if (summonType == null) { - summonType = this.getSummonType(); - } - assert this.summonType != null; - if (this.summonType.equals("lostadventurer")) { - return; - } - // TODO Add support for resource packs - try { - correctSkin = SummonSkins.INSTANCE.getSkintextureMap().get(this.getSummonType()).getResource(); - } catch (NullPointerException npe) { - mc.thePlayer.addChatComponentMessage(new ChatComponentText("§cPlease tell Skytils dev to add a skin for " + summonType)); - correctSkin = (Skytils.config.usePlayerSkin || Utils.noSychic) ? mc.thePlayer.getLocationSkin() : sychicSkin; - } - } - cir.setReturnValue(correctSkin); - } else { - cir.setReturnValue((Skytils.config.usePlayerSkin || Utils.noSychic) ? mc.thePlayer.getLocationSkin() : sychicSkin); - } - } - } - - @Inject(method = "hasSkin", at = @At("RETURN"), cancellable = true) - private void replaceHasSkin(CallbackInfoReturnable<Boolean> cir) { - if (isSummonMob()) cir.setReturnValue(true); - } - - @Inject(method = "getSkinType", at = @At("RETURN"), cancellable = true) - private void replaceSkinType(CallbackInfoReturnable<String> cir) { - if (isSummonMob()) cir.setReturnValue((Skytils.config.usePlayerSkin || Utils.noSychic) ? mc.thePlayer.getSkinType() : "slim"); - } - - @Unique - private boolean isSummonMob() { - if (isSummonMob != null) return isSummonMob; - if (!Utils.inSkyblock) return false; - try { - if ("Lost Adventurer".equals(this.getName())) { - Property textures = CollectionsKt.firstOrNull(this.getGameProfile().getProperties().get("textures")); - if (textures != null) { - isSummonMob = phoenixSkinObject.equals(textures.getValue()); - } - } - } catch(Exception e) { - isSummonMob = false; - } - if (isSummonMob == null) isSummonMob = false; - return isSummonMob; - } - - @Unique - private String getSummonType() { - if (!isSummonMob()) return null; - if (Minecraft.getMinecraft().theWorld == null) return null; - List<Entity> nearbyEntities = Minecraft.getMinecraft().theWorld.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(0.0, 1.0, 0.0), entity -> entity instanceof EntityArmorStand && entity.hasCustomName()); - for (Entity entity : nearbyEntities) { - String name = entity.getCustomNameTag(); - if (!(name.contains("'s ") && name.contains("§c❤"))) continue; - long parsedHealth = NumberUtil.unformat(name.substring(name.indexOf(" §a") + 3, name.indexOf("§c❤"))); - if ((float) parsedHealth != this.getHealth()) continue; - return name.substring(name.indexOf("'s ") + "'s ".length(), name.indexOf(" §")).replace(" ","").toLowerCase(); - } - return null; - } -} diff --git a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiContainer.java b/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiContainer.java deleted file mode 100644 index 56f0d0ad..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiContainer.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.gui; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; -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 skytils.skytilsmod.events.GuiContainerEvent; - -@Mixin(GuiContainer.class) -public abstract class MixinGuiContainer extends GuiScreen { - - @Shadow public Container inventorySlots; - - private final GuiContainer that = (GuiContainer) (Object) this; - - @Inject(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V", shift = At.Shift.BEFORE)) - private void closeWindowPressed(CallbackInfo ci) { - try { - MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.CloseWindowEvent(that, inventorySlots)); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.CloseWindowEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - } - - @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 1)) - private void backgroundDrawn(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { - try { - MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.BackgroundDrawnEvent(that, inventorySlots, mouseX, mouseY, partialTicks)); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.BackgroundDrawnEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - } - - @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) - private void onDrawSlot(Slot slot, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.DrawSlotEvent.Pre(that, inventorySlots, slot))) ci.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.DrawSlotEvent.Pre. Please report this on the Discord server.")); - e.printStackTrace(); - } - } - - @Inject(method = "drawSlot", at = @At("RETURN"), cancellable = true) - private void onDrawSlotPost(Slot slot, CallbackInfo ci) { - try { - MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.DrawSlotEvent.Post(that, inventorySlots, slot)); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.DrawSlotEvent.Post. Please report this on the Discord server.")); - e.printStackTrace(); - } - } - - - @Inject(method = "handleMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;windowClick(IIIILnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;"), cancellable = true) - private void onMouseClick(Slot slot, int slotId, int clickedButton, int clickType, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new GuiContainerEvent.SlotClickEvent(that, inventorySlots, slot, slotId, clickedButton, clickType))) ci.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.SlotClickEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - } -}
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/item/MixinItemStack.java b/src/main/java/skytils/skytilsmod/mixins/item/MixinItemStack.java deleted file mode 100644 index e051b1f6..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/item/MixinItemStack.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.item; - -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -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.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.features.impl.handlers.GlintCustomizer; -import skytils.skytilsmod.utils.ItemUtil; -import skytils.skytilsmod.utils.Utils; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -@Mixin(ItemStack.class) -public abstract class MixinItemStack { - @Shadow private NBTTagCompound stackTagCompound; - private final static Pattern starPattern = Pattern.compile("(§6✪)"); - private final static Pattern masterStarPattern = Pattern.compile("(§c✪)"); - - private final ItemStack that = (ItemStack) (Object) this; - - @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true) - private void showEnchantmentGlint(CallbackInfoReturnable<Boolean> cir) { - if (!Utils.inSkyblock) return; - NBTTagCompound extraAttr = ItemUtil.getExtraAttributes(that); - if (extraAttr != null) { - String itemId = ItemUtil.getSkyBlockItemID(extraAttr); - if (GlintCustomizer.overrides.containsKey(itemId)) { - cir.setReturnValue(GlintCustomizer.overrides.get(itemId)); - return; - } - if (Skytils.config.enchantGlintFix) { - if (extraAttr.hasKey("enchantments") && !extraAttr.getCompoundTag("enchantments").getKeySet().isEmpty()) { - cir.setReturnValue(true); - return; - } - } - } - - if (stackTagCompound != null && stackTagCompound.hasKey("SkytilsForceGlint")) { - cir.setReturnValue(stackTagCompound.getBoolean("SkytilsForceGlint")); - } - } - - @ModifyVariable(method = "getDisplayName", at = @At(value = "STORE")) - private String modifyDisplayName(String s) { - if (!Utils.inSkyblock) return s; - try { - if (Skytils.config.compactStars && s.contains("✪")) { - Matcher masterStarMatcher = masterStarPattern.matcher(s); - if (masterStarMatcher.find()) { - int count = 0; - int i = 0; - while(masterStarMatcher.find(i)) { - count ++; - i = masterStarMatcher.end(); - } - s = s.replaceAll(starPattern.toString(), "").replaceAll(masterStarPattern.toString(), "") + "§c" + (count + 5) + "✪"; - } else { - Matcher starMatcher = starPattern.matcher(s); - if (starMatcher.find()) { - int count = 0; - int i = 0; - while (starMatcher.find(i)) { - count++; - i = starMatcher.end(); - } - s = s.replaceAll(starPattern.toString(), "") + "§6" + count + "✪"; - } - } - } - } catch(Exception ignored) { } - return s; - } -} diff --git a/src/main/java/skytils/skytilsmod/mixins/model/MixinModelBlaze.java b/src/main/java/skytils/skytilsmod/mixins/model/MixinModelBlaze.java deleted file mode 100644 index d2913090..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/model/MixinModelBlaze.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.model; - -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelBlaze; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.entity.Entity; -import org.lwjgl.opengl.GL11; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.RenderUtilKt; - -import java.awt.*; - -import static skytils.skytilsmod.features.impl.dungeons.solvers.BlazeSolver.blazeMode; -import static skytils.skytilsmod.features.impl.dungeons.solvers.BlazeSolver.orderedBlazes; - -@Mixin(ModelBlaze.class) -public abstract class MixinModelBlaze extends ModelBase { - - - @Inject(method = "render", at = @At(value = "HEAD")) - private void changeBlazeColor(Entity entity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale, CallbackInfo ci) { - if (orderedBlazes.size() == 0) return; - GlStateManager.disableTexture2D(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (blazeMode <= 0) { - if (entity.isEntityEqual(orderedBlazes.get(0).blaze)) { - Color color = Skytils.config.lowestBlazeColor; - RenderUtilKt.bindColor(color); - } else if (Skytils.config.showNextBlaze && orderedBlazes.size() > 1 && entity.isEntityEqual(orderedBlazes.get(1).blaze) && blazeMode != 0) { - Color color = Skytils.config.nextBlazeColor; - RenderUtilKt.bindColor(color); - } - } - if (blazeMode >= 0) { - if (entity.isEntityEqual(orderedBlazes.get(orderedBlazes.size() - 1).blaze)) { - Color color = Skytils.config.highestBlazeColor; - RenderUtilKt.bindColor(color); - } else if (Skytils.config.showNextBlaze && orderedBlazes.size() > 1 && entity.isEntityEqual(orderedBlazes.get(orderedBlazes.size() - 2).blaze) && blazeMode != 0) { - Color color = Skytils.config.nextBlazeColor; - RenderUtilKt.bindColor(color); - } - } - } - - @Inject(method = "render", at = @At("RETURN")) - private void renderPost(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale, CallbackInfo ci) { - GlStateManager.disableBlend(); - GlStateManager.enableTexture2D(); - } -} diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerCustomHead.java b/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerCustomHead.java deleted file mode 100644 index 8077a9f5..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerCustomHead.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.renderer; - -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.entity.layers.LayerCustomHead; -import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import org.lwjgl.opengl.GL11; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; - -@Mixin(LayerCustomHead.class) -public abstract class MixinLayerCustomHead implements LayerRenderer<EntityLivingBase> { - - @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", shift = At.Shift.AFTER), cancellable = true) - private void renderCustomHeadLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { - if (!Utils.inSkyblock) return; - if (entity instanceof EntityPlayerSP) { - if (Skytils.config.transparentHeadLayer == 0) { - GlStateManager.popMatrix(); - ci.cancel(); - return; - } - if (Skytils.config.transparentHeadLayer != 1) { - if (entity.hurtTime > 0) { - // See net.minecraft.client.renderer.entity.RendererLivingEntity.unsetBrightness - GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); - GlStateManager.enableTexture2D(); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, OpenGlHelper.defaultTexUnit); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PRIMARY_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, OpenGlHelper.defaultTexUnit); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_ALPHA, OpenGlHelper.GL_PRIMARY_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_ALPHA, GL11.GL_SRC_ALPHA); - GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, GL11.GL_TEXTURE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PREVIOUS); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, GL11.GL_TEXTURE); - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - GlStateManager.setActiveTexture(OpenGlHelper.GL_TEXTURE2); - GlStateManager.disableTexture2D(); - GlStateManager.bindTexture(0); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, GL11.GL_TEXTURE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PREVIOUS); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA); - GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, GL11.GL_TEXTURE); - GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit); - } - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(1, 1, 1, Skytils.config.transparentHeadLayer); - } - } - } - - @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V")) - private void renderCustomHeadLayerPost(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { - GlStateManager.disableBlend(); - } - - @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V"), cancellable = true) - private void renderGlintOnSkull(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { - ItemStack itemStack = entitylivingbaseIn.getCurrentArmor(3); - if (Utils.inSkyblock && Skytils.config.enchantGlintFix && itemStack.hasEffect()) { - Utils.lastRenderedSkullStack = itemStack; - Utils.lastRenderedSkullEntity = entitylivingbaseIn; - } - } - -} diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderItem.java b/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderItem.java deleted file mode 100644 index 5e6aada8..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderItem.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.renderer; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; -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 skytils.skytilsmod.Skytils; -import skytils.skytilsmod.events.GuiRenderItemEvent; -import skytils.skytilsmod.features.impl.handlers.GlintCustomizer; -import skytils.skytilsmod.utils.ItemUtil; -import skytils.skytilsmod.utils.NEUCompatibility; -import skytils.skytilsmod.utils.RenderUtil; -import skytils.skytilsmod.utils.Utils; - -@Mixin(RenderItem.class) -public abstract class MixinRenderItem { - - private final Minecraft mc = Minecraft.getMinecraft(); - - @Shadow @Final private static ResourceLocation RES_ITEM_GLINT; - - @Shadow @Final private TextureManager textureManager; - - @Shadow protected abstract void renderModel(IBakedModel model, int color); - - @Inject(method = "renderItemIntoGUI", at = @At("HEAD")) - private void renderRarity(ItemStack stack, int x, int y, CallbackInfo ci) { - if (Utils.inSkyblock && Skytils.config.showItemRarity) { - if (mc.currentScreen != null) { - String name = mc.currentScreen.getClass().getName(); - if (NEUCompatibility.INSTANCE.isStorageMenuActive() || NEUCompatibility.INSTANCE.isTradeWindowActive() || NEUCompatibility.INSTANCE.isCustomAHActive()) { - RenderUtil.renderRarity(stack, x, y); - } - } - } - } - - @Inject(method = "renderItemOverlayIntoGUI", at = @At("RETURN")) - private void renderItemOverlayPost(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { - try { - MinecraftForge.EVENT_BUS.post(new GuiRenderItemEvent.RenderOverlayEvent.Post(fr, stack, xPosition, yPosition, text)); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at GuiRenderItemEvent.RenderOverlayEvent.Post. Please report this on the Discord server.")); - e.printStackTrace(); - } - } - - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/GlStateManager.scale(FFF)V", shift = At.Shift.AFTER)) - private void renderItemPre(ItemStack stack, IBakedModel model, CallbackInfo ci) { - if (!Utils.inSkyblock) return; - if (stack.getItem() == Items.skull) { - double scale = Skytils.config.largerHeadScale; - GlStateManager.scale(scale, scale, scale); - } - } - - @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderEffect(Lnet/minecraft/client/resources/model/IBakedModel;)V", shift = At.Shift.BEFORE), cancellable = true) - private void modifyGlintRendering(ItemStack stack, IBakedModel model, CallbackInfo ci) { - if (Utils.inSkyblock) { - String itemId = ItemUtil.getSkyBlockItemID(stack); - if (GlintCustomizer.glintColors.containsKey(itemId)) { - int color = GlintCustomizer.glintColors.get(itemId).toInt(); - - GlStateManager.depthMask(false); - GlStateManager.depthFunc(514); - GlStateManager.disableLighting(); - GlStateManager.blendFunc(768, 1); - this.textureManager.bindTexture(RES_ITEM_GLINT); - GlStateManager.matrixMode(5890); - GlStateManager.pushMatrix(); - GlStateManager.scale(8.0F, 8.0F, 8.0F); - float f = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F / 8.0F; - GlStateManager.translate(f, 0.0F, 0.0F); - GlStateManager.rotate(-50.0F, 0.0F, 0.0F, 1.0F); - this.renderModel(model, color); - GlStateManager.popMatrix(); - GlStateManager.pushMatrix(); - GlStateManager.scale(8.0F, 8.0F, 8.0F); - float f1 = (float)(Minecraft.getSystemTime() % 4873L) / 4873.0F / 8.0F; - GlStateManager.translate(-f1, 0.0F, 0.0F); - GlStateManager.rotate(10.0F, 0.0F, 0.0F, 1.0F); - this.renderModel(model, color); - GlStateManager.popMatrix(); - GlStateManager.matrixMode(5888); - GlStateManager.blendFunc(770, 771); - GlStateManager.enableLighting(); - GlStateManager.depthFunc(515); - GlStateManager.depthMask(true); - this.textureManager.bindTexture(TextureMap.locationBlocksTexture); - - ci.cancel(); - - //Since we prematurely exited, we need to reset the matrices - GlStateManager.popMatrix(); - } - } - } - -} diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntitySkullRenderer.java b/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntitySkullRenderer.java deleted file mode 100644 index 4fa84bb8..00000000 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntitySkullRenderer.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Skytils - Hypixel Skyblock Quality of Life Mod - * Copyright (C) 2021 Skytils - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package skytils.skytilsmod.mixins.renderer; - -import com.mojang.authlib.GameProfile; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelSkeletonHead; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.tileentity.TileEntitySkull; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.ResourceLocation; -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 skytils.skytilsmod.features.impl.handlers.GlintCustomizer; -import skytils.skytilsmod.utils.ItemUtil; -import skytils.skytilsmod.utils.RenderUtil; -import skytils.skytilsmod.utils.Utils; -import skytils.skytilsmod.utils.graphics.colors.CustomColor; -import static skytils.skytilsmod.Skytils.getMc; - - -@Mixin(TileEntitySkullRenderer.class) -public abstract class MixinTileEntitySkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull> { - - @Shadow @Final private ModelSkeletonHead humanoidHead; - @Shadow @Final private ModelSkeletonHead skeletonHead; - @Shadow public static TileEntitySkullRenderer instance; - private static final ResourceLocation ENCHANTED_ITEM_GLINT_RES = new ResourceLocation("textures/misc/enchanted_item_glint.png"); - - /** - * @see MixinLayerArmorBase - */ - @Inject(method = "renderSkull", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelBase;render(Lnet/minecraft/entity/Entity;FFFFFF)V", shift = At.Shift.AFTER)) - private void addGlintToSkull(float x, float y, float z, EnumFacing face, float rotation, int type, GameProfile profile, int p_180543_8_, CallbackInfo ci) { - if (Utils.lastRenderedSkullStack != null && Utils.lastRenderedSkullEntity != null) { - ModelBase model = type == 2 || type == 3 ? this.humanoidHead : this.skeletonHead; - String itemId = ItemUtil.getSkyBlockItemID(Utils.lastRenderedSkullStack); - if (GlintCustomizer.glintColors.containsKey(itemId)) { - CustomColor color = GlintCustomizer.glintColors.get(itemId); - renderGlint(Utils.lastRenderedSkullEntity, model, rotation, color); - } else renderGlint(Utils.lastRenderedSkullEntity, model, rotation,null); - Utils.lastRenderedSkullStack = null; - Utils.lastRenderedSkullEntity = null; - } - } - - private void renderGlint(EntityLivingBase entity, ModelBase model, float rotation, CustomColor color) { - float partialTicks = RenderUtil.INSTANCE.getPartialTicks(); - float f = (float)entity.ticksExisted + partialTicks; - getMc().getTextureManager().bindTexture(ENCHANTED_ITEM_GLINT_RES); - GlStateManager.enableBlend(); - GlStateManager.depthFunc(514); - GlStateManager.depthMask(false); - float f1 = 0.5F; - GlStateManager.color(f1, f1, f1, 1.0F); - //GlintCustomizer.glintColors.get(itemId).applyColor(); - - for (int i = 0; i < 2; ++i) - { - GlStateManager.disableLighting(); - GlStateManager.blendFunc(768, 1); - float f2 = 0.76F; - if (color == null) GlStateManager.color(0.5F * f2, 0.25F * f2, 0.8F * f2, 1.0F); - else color.applyColor(); - GlStateManager.matrixMode(5890); - GlStateManager.loadIdentity(); - float f3 = 0.33333334F; - GlStateManager.scale(f3, f3, f3); - GlStateManager.rotate(30.0F - (float)i * 60.0F, 0.0F, 0.0F, 1.0F); - GlStateManager.translate(0.0F, f * (0.001F + (float)i * 0.003F) * 20.0F, 0.0F); - GlStateManager.matrixMode(5888); - model.render(null, 0, 0, 0, rotation, 0, f); - } - - GlStateManager.matrixMode(5890); - GlStateManager.loadIdentity(); - GlStateManager.matrixMode(5888); - GlStateManager.enableLighting(); - GlStateManager.depthMask(true); - GlStateManager.depthFunc(515); - //GlStateManager.disableBlend(); - GlStateManager.blendFunc(770, 771); - } - -} diff --git a/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java b/src/main/java/skytils/skytilsmod/mixins/transformers/MixinMinecraft.java index 392fb01a..f2f93faf 100644 --- a/src/main/java/skytils/skytilsmod/mixins/MixinMinecraft.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/MixinMinecraft.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins; +package skytils.skytilsmod.mixins.transformers; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorCommandHandler.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorCommandHandler.java index ba444564..6c56e328 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorCommandHandler.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorCommandHandler.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.command.CommandHandler; import net.minecraft.command.ICommand; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorEnumDyeColor.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorEnumDyeColor.java index b25cd64a..d217157d 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorEnumDyeColor.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorEnumDyeColor.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.item.EnumDyeColor; import net.minecraft.util.EnumChatFormatting; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiContainer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiContainer.java index de56a11d..ff81a9ca 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiContainer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiContainer.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.client.gui.inventory.GuiContainer; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiEditSign.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiEditSign.java index 910ffaca..91bf9e20 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiEditSign.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiEditSign.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiEditSign; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiNewChat.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiNewChat.java index 8892e055..2be0dbd8 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorGuiNewChat.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorGuiNewChat.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.GuiNewChat; diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorMinecraft.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorMinecraft.java index dbe07d10..ca0dc9bf 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorMinecraft.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorMinecraft.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import net.minecraft.client.Minecraft; import net.minecraft.util.Timer; diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorRenderItem.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorRenderItem.java new file mode 100644 index 00000000..1b0b0d81 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorRenderItem.java @@ -0,0 +1,30 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.accessors; + +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.model.IBakedModel; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(RenderItem.class) +public interface AccessorRenderItem { + @Invoker + void invokeRenderModel(IBakedModel model, int color); +} diff --git a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorSettingsGui.java b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorSettingsGui.java index 1c601061..50de4a6c 100644 --- a/src/main/java/skytils/skytilsmod/mixins/accessors/AccessorSettingsGui.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/accessors/AccessorSettingsGui.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.accessors; +package skytils.skytilsmod.mixins.transformers.accessors; import gg.essential.vigilance.Vigilant; import gg.essential.vigilance.gui.SettingsGui; diff --git a/src/main/java/skytils/skytilsmod/mixins/audio/MixinSoundManager.java b/src/main/java/skytils/skytilsmod/mixins/transformers/audio/MixinSoundManager.java index 3aecf721..7b313e7a 100644 --- a/src/main/java/skytils/skytilsmod/mixins/audio/MixinSoundManager.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/audio/MixinSoundManager.java @@ -16,9 +16,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.audio; +package skytils.skytilsmod.mixins.transformers.audio; -import kotlin.text.StringsKt; import net.minecraft.client.audio.ISound; import net.minecraft.client.audio.SoundCategory; import net.minecraft.client.audio.SoundManager; @@ -28,21 +27,18 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.audio.SoundManagerHookKt; @Mixin(SoundManager.class) public abstract class MixinSoundManager { @Inject(method = "getNormalizedVolume", at = @At("HEAD"), cancellable = true) private void bypassPlayerVolume(ISound sound, SoundPoolEntry entry, SoundCategory category, CallbackInfoReturnable<Float> cir) { - if (Utils.shouldBypassVolume) cir.setReturnValue(1f); + SoundManagerHookKt.bypassPlayerVolume(sound, entry, category, cir); } @Inject(method = "playSound", at = @At("HEAD"), cancellable = true) private void stopPlayingUnknownSounds(ISound p_sound, CallbackInfo ci) { - if (StringsKt.isBlank(p_sound.getSoundLocation().getResourcePath()) && Utils.isOnHypixel && Skytils.config.preventLogSpam) { - ci.cancel(); - } + SoundManagerHookKt.stopPlayingUnknownSounds(p_sound, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/crash/MixinCrashReport.java b/src/main/java/skytils/skytilsmod/mixins/transformers/crash/MixinCrashReport.java index 0d3e04a6..41be4b46 100644 --- a/src/main/java/skytils/skytilsmod/mixins/crash/MixinCrashReport.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/crash/MixinCrashReport.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.crash; +package skytils.skytilsmod.mixins.transformers.crash; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; @@ -29,7 +29,6 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; import skytils.skytilsmod.utils.Utils; @Mixin(value = CrashReport.class, priority = 1001) diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinAbstractClientPlayer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinAbstractClientPlayer.java new file mode 100644 index 00000000..7ce74320 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinAbstractClientPlayer.java @@ -0,0 +1,56 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.entity; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +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.CallbackInfoReturnable; +import skytils.skytilsmod.mixins.hooks.entity.AbstractClientPlayerHook; + +@Mixin(AbstractClientPlayer.class) +public abstract class MixinAbstractClientPlayer extends EntityPlayer { + public MixinAbstractClientPlayer(World worldIn, GameProfile gameProfileIn) { + super(worldIn, gameProfileIn); + } + + @Unique + private final AbstractClientPlayerHook hook = new AbstractClientPlayerHook(this); + + @Inject(method = "getLocationSkin()Lnet/minecraft/util/ResourceLocation;", at = @At("RETURN"), cancellable = true) + private void replaceSkin(CallbackInfoReturnable<ResourceLocation> cir) { + hook.replaceSkin(cir); + } + + @Inject(method = "hasSkin", at = @At("RETURN"), cancellable = true) + private void replaceHasSkin(CallbackInfoReturnable<Boolean> cir) { + hook.replaceHasSkin(cir); + } + + @Inject(method = "getSkinType", at = @At("RETURN"), cancellable = true) + private void replaceSkinType(CallbackInfoReturnable<String> cir) { + hook.replaceSkinType(cir); + } +} diff --git a/src/main/java/skytils/skytilsmod/mixins/entity/MixinBossStatus.java b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinBossStatus.java index ba9c7d10..07e384d2 100644 --- a/src/main/java/skytils/skytilsmod/mixins/entity/MixinBossStatus.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinBossStatus.java @@ -16,29 +16,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.entity; +package skytils.skytilsmod.mixins.transformers.entity; -import net.minecraft.client.Minecraft; import net.minecraft.entity.boss.BossStatus; import net.minecraft.entity.boss.IBossDisplayData; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.events.BossBarEvent; +import skytils.skytilsmod.mixins.hooks.entity.BossStatusHookKt; @Mixin(BossStatus.class) public abstract class MixinBossStatus { @Inject(method = "setBossStatus", at = @At("HEAD"), cancellable = true) private static void onSetBossStatus(IBossDisplayData displayData, boolean hasColorModifierIn, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new BossBarEvent.Set(displayData, hasColorModifierIn))) ci.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at BossBarEvent.Set. Please report this on the Discord server.")); - e.printStackTrace(); - } + BossStatusHookKt.onSetBossStatus(displayData, hasColorModifierIn, ci); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityBlaze.java b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityBlaze.java index 01bf61ca..dcbaa082 100644 --- a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityBlaze.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityBlaze.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.entity; +package skytils.skytilsmod.mixins.transformers.entity; import net.minecraft.entity.monster.EntityBlaze; import net.minecraft.entity.monster.EntityMob; @@ -25,7 +25,7 @@ import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.entity.EntityBlazeHookKt; @Mixin(EntityBlaze.class) public abstract class MixinEntityBlaze extends EntityMob { @@ -36,8 +36,6 @@ public abstract class MixinEntityBlaze extends EntityMob { @Redirect(method = "onLivingUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V")) private void spawnParticle(World world, EnumParticleTypes particleType, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175688_14_) { - if (particleType != EnumParticleTypes.SMOKE_LARGE || !Utils.inDungeons) { - world.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); - } + EntityBlazeHookKt.removeBlazeSmokeParticle(world, particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityLivingBase.java b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityLivingBase.java index 65d4620d..5ee1298c 100644 --- a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityLivingBase.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityLivingBase.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.entity; +package skytils.skytilsmod.mixins.transformers.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -28,8 +28,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.entity.EntityLivingBaseHookKt; @Mixin(EntityLivingBase.class) public abstract class MixinEntityLivingBase extends Entity { @@ -40,24 +39,16 @@ public abstract class MixinEntityLivingBase extends Entity { @Inject(method = "isPotionActive(Lnet/minecraft/potion/Potion;)Z", at = @At("HEAD"), cancellable = true) private void modifyPotionActive(Potion potion, CallbackInfoReturnable<Boolean> cir) { - if (!Utils.inSkyblock) return; - if (Skytils.config.disableNightVision && potion == Potion.nightVision) { - cir.setReturnValue(false); - } + EntityLivingBaseHookKt.modifyPotionActive(potion, cir); } @Inject(method = "isPotionActive(I)Z", at = @At("HEAD"), cancellable = true) private void modifyPotionActive(int potionId, CallbackInfoReturnable<Boolean> cir) { - if (!Utils.inSkyblock) return; - if (Skytils.config.disableNightVision && potionId == Potion.nightVision.id) { - cir.setReturnValue(false); - } + EntityLivingBaseHookKt.modifyPotionActive(potionId, cir); } @Redirect(method = "onDeathUpdate", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnParticle(Lnet/minecraft/util/EnumParticleTypes;DDDDDD[I)V")) private void spawnParticle(World world, EnumParticleTypes particleType, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int[] p_175688_14_) { - if (!(Skytils.config.hideDeathParticles && particleType.equals(EnumParticleTypes.EXPLOSION_NORMAL))) { - world.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); - } + EntityLivingBaseHookKt.removeDeathParticle(world, particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, p_175688_14_); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityPlayerSP.java b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityPlayerSP.java index daad7294..08481f64 100644 --- a/src/main/java/skytils/skytilsmod/mixins/entity/MixinEntityPlayerSP.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/entity/MixinEntityPlayerSP.java @@ -16,26 +16,22 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.entity; +package skytils.skytilsmod.mixins.transformers.entity; import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.entity.item.EntityItem; -import net.minecraft.item.ItemStack; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; 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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.events.AddChatMessageEvent; -import skytils.skytilsmod.events.ItemTossEvent; +import skytils.skytilsmod.mixins.hooks.entity.EntityPlayerSPHookKt; @Mixin(EntityPlayerSP.class) public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { @@ -47,22 +43,11 @@ public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { @Inject(method = "addChatMessage", at = @At("HEAD"), cancellable = true) private void onAddChatMessage(IChatComponent message, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new AddChatMessageEvent(message))) ci.cancel(); - } catch (Throwable e) { - mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at AddChatMessageEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + EntityPlayerSPHookKt.onAddChatMessage(message, ci); } @Inject(method = "dropOneItem", at = @At("HEAD"), cancellable = true) private void onDropItem(boolean dropAll, CallbackInfoReturnable<EntityItem> cir) { - try { - ItemStack stack = inventory.getCurrentItem(); - if (stack != null && MinecraftForge.EVENT_BUS.post(new ItemTossEvent(stack, dropAll))) cir.setReturnValue(null); - } catch (Throwable e) { - mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at PlayerDropItemEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + EntityPlayerSPHookKt.onDropItem(dropAll, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/forge/MixinSplashProgress.java b/src/main/java/skytils/skytilsmod/mixins/transformers/forge/MixinSplashProgress.java index 75d297da..a79d4780 100644 --- a/src/main/java/skytils/skytilsmod/mixins/forge/MixinSplashProgress.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/forge/MixinSplashProgress.java @@ -16,19 +16,19 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.forge; +package skytils.skytilsmod.mixins.transformers.forge; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.SplashProgress; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.forge.SplashProgressHookKt; @Mixin(value = SplashProgress.class, priority = 0x7fffffff) public abstract class MixinSplashProgress { @ModifyVariable(method = "start", at = @At(value = "STORE"), ordinal = 2, remap = false) private static ResourceLocation setForgeGif(ResourceLocation resourceLocation) { - return Utils.noSychic ? resourceLocation : new ResourceLocation("skytils", "sychicpet.gif"); + return SplashProgressHookKt.setForgeGif(resourceLocation); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiContainer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiContainer.java new file mode 100644 index 00000000..9e40b221 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiContainer.java @@ -0,0 +1,62 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.gui; + +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +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; +import skytils.skytilsmod.mixins.hooks.gui.GuiContainerHook; + +@Mixin(GuiContainer.class) +public abstract class MixinGuiContainer extends GuiScreen { + + @Unique + private final GuiContainerHook hook = new GuiContainerHook(this); + + @Inject(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/entity/EntityPlayerSP;closeScreen()V", shift = At.Shift.BEFORE)) + private void closeWindowPressed(CallbackInfo ci) { + hook.closeWindowPressed(ci); + } + + @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", ordinal = 1)) + private void backgroundDrawn(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { + hook.backgroundDrawn(mouseX, mouseY, partialTicks, ci); + } + + @Inject(method = "drawSlot", at = @At("HEAD"), cancellable = true) + private void onDrawSlot(Slot slot, CallbackInfo ci) { + hook.onDrawSlot(slot, ci); + } + + @Inject(method = "drawSlot", at = @At("RETURN"), cancellable = true) + private void onDrawSlotPost(Slot slot, CallbackInfo ci) { + hook.onDrawSlotPost(slot, ci); + } + + + @Inject(method = "handleMouseClick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/multiplayer/PlayerControllerMP;windowClick(IIIILnet/minecraft/entity/player/EntityPlayer;)Lnet/minecraft/item/ItemStack;"), cancellable = true) + private void onMouseClick(Slot slot, int slotId, int clickedButton, int clickType, CallbackInfo ci) { + hook.onMouseClick(slot, slotId, clickedButton, clickType, ci); + } +}
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiIngame.java b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiIngame.java index df8f06e7..8fbd9352 100644 --- a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiIngame.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiIngame.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.gui; +package skytils.skytilsmod.mixins.transformers.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -31,6 +31,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import skytils.skytilsmod.Skytils; import skytils.skytilsmod.events.SetActionBarEvent; +import skytils.skytilsmod.mixins.hooks.gui.GuiIngameHookKt; import skytils.skytilsmod.utils.RenderUtil; import skytils.skytilsmod.utils.Utils; @@ -45,29 +46,16 @@ public abstract class MixinGuiIngame extends Gui { @Inject(method = "setRecordPlaying(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true) private void onSetActionBar(String message, boolean isPlaying, CallbackInfo ci) { - try { - SetActionBarEvent event = new SetActionBarEvent(message, isPlaying); - if (MinecraftForge.EVENT_BUS.post(event)) { - ci.cancel(); - return; - } - if (!message.equals(event.getMessage()) || isPlaying != event.isPlaying()) { - ci.cancel(); - this.recordPlaying = event.getMessage(); - this.recordPlayingUpFor = 60; - this.recordIsPlaying = event.isPlaying(); - } - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at SetActionBarEvent. Please report this on the Discord server.")); - e.printStackTrace(); + if (GuiIngameHookKt.onSetActionBar(message, isPlaying, ci)) { + this.recordPlaying = GuiIngameHookKt.getRecordPlaying(); + this.recordPlayingUpFor = GuiIngameHookKt.getRecordPlayingUpFor(); + this.recordIsPlaying = GuiIngameHookKt.getRecordIsPlaying(); } } @Inject(method = "renderHotbarItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderItemAndEffectIntoGUI(Lnet/minecraft/item/ItemStack;II)V")) private void renderRarityOnHotbar(int index, int xPos, int yPos, float partialTicks, EntityPlayer player, CallbackInfo ci) { - if (Utils.inSkyblock && Skytils.config.showItemRarity) { - RenderUtil.renderRarity(player.inventory.mainInventory[index], xPos, yPos); - } + GuiIngameHookKt.renderRarityOnHotbar(index, xPos, yPos, partialTicks, player, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiIngameForge.java b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiIngameForge.java index e6eb0d35..5e2e7e4b 100644 --- a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiIngameForge.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiIngameForge.java @@ -16,20 +16,16 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.gui; +package skytils.skytilsmod.mixins.transformers.gui; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiIngame; import net.minecraftforge.client.GuiIngameForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArgs; import org.spongepowered.asm.mixin.injection.invoke.arg.Args; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.core.structure.GuiElement; -import skytils.skytilsmod.features.impl.misc.MiscFeatures; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.gui.GuiIngameForgeHookKt; @Mixin(GuiIngameForge.class) public abstract class MixinGuiIngameForge extends GuiIngame { @@ -39,27 +35,11 @@ public abstract class MixinGuiIngameForge extends GuiIngame { @ModifyArgs(method = "renderToolHightlight", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I")) private void modifyItemHighlightPosition(Args args) { - if (Skytils.config.moveableItemNameHighlight && Utils.inSkyblock) { - FontRenderer fr = highlightingItemStack.getItem().getFontRenderer(highlightingItemStack); - if (fr == null) fr = mc.fontRendererObj; - - String itemName = args.get(0); - - GuiElement element = MiscFeatures.ItemNameHighlightDummy.INSTANCE; - - float x = element.getActualX() - fr.getStringWidth(itemName) / 2f; - - args.set(1, x); - args.set(2, element.getActualY()); - } + GuiIngameForgeHookKt.modifyItemHighlightPosition(args, highlightingItemStack); } @ModifyArgs(method = "renderRecordOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V")) private void modifyActionBarPosition(Args args) { - if (Skytils.config.moveableActionBar && Utils.inSkyblock) { - GuiElement element = MiscFeatures.ActionBarDummy.INSTANCE; - args.set(0, element.getActualX()); - args.set(1, element.getActualY() + 4f); - } + GuiIngameForgeHookKt.modifyActionBarPosition(args); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiScreen.java b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiScreen.java index 4f8da820..8c4a9bcc 100644 --- a/src/main/java/skytils/skytilsmod/mixins/gui/MixinGuiScreen.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/gui/MixinGuiScreen.java @@ -16,35 +16,23 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.gui; +package skytils.skytilsmod.mixins.transformers.gui; -import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiYesNoCallback; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.events.SendChatMessageEvent; +import skytils.skytilsmod.mixins.hooks.gui.GuiScreenHookKt; @Mixin(GuiScreen.class) public abstract class MixinGuiScreen extends Gui implements GuiYesNoCallback { @Inject(method = "sendChatMessage(Ljava/lang/String;Z)V", at = @At("HEAD"), cancellable = true) private void onSendChatMessage(String message, boolean addToChat, CallbackInfo ci) { - try { - SendChatMessageEvent event = new SendChatMessageEvent(message, addToChat); - if (MinecraftForge.EVENT_BUS.post(event)) { - ci.cancel(); - } - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at SendChatMessageEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - + GuiScreenHookKt.onSendChatMessage(message, addToChat, ci); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/inventory/MixinSlot.java b/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java index ee9dc240..e8a26d9c 100644 --- a/src/main/java/skytils/skytilsmod/mixins/inventory/MixinSlot.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/inventory/MixinSlot.java @@ -16,44 +16,26 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.inventory; +package skytils.skytilsmod.mixins.transformers.inventory; -import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -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.CallbackInfoReturnable; -import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.SelectAllColorSolver; -import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.StartsWithSequenceSolver; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.inventory.SlotHook; @Mixin(Slot.class) public abstract class MixinSlot { - @Shadow public abstract ItemStack getStack(); - - @Shadow @Final public IInventory inventory; - @Shadow @Final private int slotIndex; - @Shadow public int slotNumber; + @Unique + private final SlotHook hook = new SlotHook(this); @Inject(method = "getStack", at = @At("HEAD"), cancellable = true) private void markTerminalItems(CallbackInfoReturnable<ItemStack> cir) { - if (!Utils.inSkyblock) return; - ItemStack item = this.inventory.getStackInSlot(this.slotIndex); - if (item == null) return; - item = item.copy(); - if (!item.isItemEnchanted() && (SelectAllColorSolver.shouldClick.contains(this.slotNumber) || StartsWithSequenceSolver.shouldClick.contains(this.slotNumber))) { - if (item.getTagCompound() == null) { - item.setTagCompound(new NBTTagCompound()); - } - item.getTagCompound().setBoolean("SkytilsForceGlint", true); - cir.setReturnValue(item); - } + hook.markTerminalItems(cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/item/MixinItemArmor.java b/src/main/java/skytils/skytilsmod/mixins/transformers/item/MixinItemArmor.java index ecc226cb..7bc599db 100644 --- a/src/main/java/skytils/skytilsmod/mixins/item/MixinItemArmor.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/item/MixinItemArmor.java @@ -16,56 +16,32 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.item; +package skytils.skytilsmod.mixins.transformers.item; import net.minecraft.item.Item; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.features.impl.handlers.ArmorColor; -import skytils.skytilsmod.utils.ItemUtil; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.item.ItemArmorHookKt; @Mixin(ItemArmor.class) public abstract class MixinItemArmor extends Item { @Inject(method = "getColor", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getTagCompound()Lnet/minecraft/nbt/NBTTagCompound;"), cancellable = true) private void replaceArmorColor(ItemStack stack, CallbackInfoReturnable<Integer> cir) { - if (!Utils.inSkyblock) return; - NBTTagCompound extraAttributes = ItemUtil.getExtraAttributes(stack); - if (extraAttributes != null && extraAttributes.hasKey("uuid")) { - String uuid = extraAttributes.getString("uuid"); - if (ArmorColor.armorColors.containsKey(uuid)) { - cir.setReturnValue(ArmorColor.armorColors.get(uuid).toInt()); - } - } + ItemArmorHookKt.replaceArmorColor(stack, cir); } @Inject(method = "getColorFromItemStack", at = @At("HEAD"), cancellable = true) private void replaceStackArmorColor(ItemStack stack, int renderPass, CallbackInfoReturnable<Integer> cir) { - if (!Utils.inSkyblock) return; - NBTTagCompound extraAttributes = ItemUtil.getExtraAttributes(stack); - if (extraAttributes != null && extraAttributes.hasKey("uuid")) { - String uuid = extraAttributes.getString("uuid"); - if (ArmorColor.armorColors.containsKey(uuid)) { - cir.setReturnValue(ArmorColor.armorColors.get(uuid).toInt()); - } - } + ItemArmorHookKt.replaceArmorColor(stack, cir); } @Inject(method = "hasColor", at = @At("HEAD"), cancellable = true) private void hasCustomArmorColor(ItemStack stack, CallbackInfoReturnable<Boolean> cir) { - if (!Utils.inSkyblock) return; - NBTTagCompound extraAttributes = ItemUtil.getExtraAttributes(stack); - if (extraAttributes != null && extraAttributes.hasKey("uuid")) { - String uuid = extraAttributes.getString("uuid"); - if (ArmorColor.armorColors.containsKey(uuid)) { - cir.setReturnValue(true); - } - } + ItemArmorHookKt.hasCustomArmorColor(stack, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/item/MixinItemStack.java b/src/main/java/skytils/skytilsmod/mixins/transformers/item/MixinItemStack.java new file mode 100644 index 00000000..9b80ac7a --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/item/MixinItemStack.java @@ -0,0 +1,40 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.item; + +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import skytils.skytilsmod.mixins.hooks.item.ItemStackHookKt; + +@Mixin(ItemStack.class) +public abstract class MixinItemStack { + @Inject(method = "hasEffect", at = @At("HEAD"), cancellable = true) + private void showEnchantmentGlint(CallbackInfoReturnable<Boolean> cir) { + ItemStackHookKt.showEnchantmentGlint(this, cir); + } + + @ModifyVariable(method = "getDisplayName", at = @At(value = "STORE")) + private String modifyDisplayName(String s) { + return ItemStackHookKt.modifyDisplayName(s); + } +} diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/model/MixinModelBlaze.java b/src/main/java/skytils/skytilsmod/mixins/transformers/model/MixinModelBlaze.java new file mode 100644 index 00000000..843104cf --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/model/MixinModelBlaze.java @@ -0,0 +1,43 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.model; + +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelBlaze; +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import skytils.skytilsmod.mixins.hooks.model.ModelBlazeHookKt; + +@Mixin(ModelBlaze.class) +public abstract class MixinModelBlaze extends ModelBase { + + + @Inject(method = "render", at = @At(value = "HEAD")) + private void changeBlazeColor(Entity entity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale, CallbackInfo ci) { + ModelBlazeHookKt.changeBlazeColor(entity, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, ci); + } + + @Inject(method = "render", at = @At("RETURN")) + private void renderPost(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale, CallbackInfo ci) { + ModelBlazeHookKt.renderModelBlazePost(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale, ci); + } +} diff --git a/src/main/java/skytils/skytilsmod/mixins/multiplayer/MixinPlayerControllerMP.java b/src/main/java/skytils/skytilsmod/mixins/transformers/multiplayer/MixinPlayerControllerMP.java index c5361d45..0a107ee0 100644 --- a/src/main/java/skytils/skytilsmod/mixins/multiplayer/MixinPlayerControllerMP.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/multiplayer/MixinPlayerControllerMP.java @@ -16,64 +16,34 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.multiplayer; +package skytils.skytilsmod.mixins.transformers.multiplayer; -import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.PlayerControllerMP; import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumFacing; import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.common.MinecraftForge; -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.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.events.DamageBlockEvent; -import skytils.skytilsmod.utils.ItemUtil; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.multiplayer.PlayerControllerMPHookKt; @Mixin(PlayerControllerMP.class) public abstract class MixinPlayerControllerMP { - - @Final - @Shadow - private Minecraft mc; - @Inject(method = "isPlayerRightClickingOnEntity", at = @At("HEAD"), cancellable = true) private void onRightClickEntity(EntityPlayer player, Entity target, MovingObjectPosition movingObject, CallbackInfoReturnable<Boolean> cir) { - handleRightClickEntity(player, target, cir); + PlayerControllerMPHookKt.handleRightClickEntity(player, target, movingObject, cir); } @Inject(method = "interactWithEntitySendPacket", at = @At("HEAD"), cancellable = true) private void onInteractWithEntitySendPacket(EntityPlayer player, Entity target, CallbackInfoReturnable<Boolean> cir) { - handleRightClickEntity(player, target, cir); - } - - private void handleRightClickEntity(EntityPlayer player, Entity target, CallbackInfoReturnable<Boolean> cir) { - if (!Skytils.config.prioritizeItemAbilities || !Utils.inSkyblock || Utils.inDungeons) return; - ItemStack item = player.getHeldItem(); - if (item != null && !(target instanceof EntityArmorStand)) { - if (ItemUtil.hasRightClickAbility(item)) { - cir.setReturnValue(false); - } - } + PlayerControllerMPHookKt.handleRightClickEntity(player, target, null, cir); } @Inject(method = "onPlayerDamageBlock", at = @At("HEAD"), cancellable = true) private void onPlayerDamageBlock(BlockPos pos, EnumFacing directionFacing, CallbackInfoReturnable<Boolean> cir) { - try { - if (MinecraftForge.EVENT_BUS.post(new DamageBlockEvent(pos, directionFacing))) cir.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at DamageBlockEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + PlayerControllerMPHookKt.onPlayerDamageBlock(pos, directionFacing, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/network/MixinNetHandlerPlayClient.java b/src/main/java/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java index 3384a3a0..dec65eb4 100644 --- a/src/main/java/skytils/skytilsmod/mixins/network/MixinNetHandlerPlayClient.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/network/MixinNetHandlerPlayClient.java @@ -16,29 +16,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.network; +package skytils.skytilsmod.mixins.transformers.network; -import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetHandlerPlayClient; import net.minecraft.network.Packet; import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.events.PacketEvent; +import skytils.skytilsmod.mixins.hooks.network.NetHandlerPlayClientHookKt; @Mixin(value = NetHandlerPlayClient.class, priority = 1001) public abstract class MixinNetHandlerPlayClient implements INetHandlerPlayClient { @Inject(method = "addToSendQueue", at = @At("HEAD"), cancellable = true) private void onSendPacket(Packet<?> packet, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new PacketEvent.SendEvent(packet))) ci.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at PacketEvent.SendEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + NetHandlerPlayClientHookKt.onSendPacket(packet, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/network/MixinNetworkManager.java b/src/main/java/skytils/skytilsmod/mixins/transformers/network/MixinNetworkManager.java index d08b5fd6..aa371f37 100644 --- a/src/main/java/skytils/skytilsmod/mixins/network/MixinNetworkManager.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/network/MixinNetworkManager.java @@ -16,30 +16,22 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.network; +package skytils.skytilsmod.mixins.transformers.network; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; -import net.minecraft.client.Minecraft; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.events.PacketEvent; +import skytils.skytilsmod.mixins.hooks.network.NetworkManagerHookKt; @Mixin(value = NetworkManager.class, priority = 1001) public abstract class MixinNetworkManager extends SimpleChannelInboundHandler<Packet<?>> { @Inject(method = "channelRead0", at = @At("HEAD"), cancellable = true) private void onReceivePacket(ChannelHandlerContext context, Packet<?> packet, CallbackInfo ci) { - try { - if (MinecraftForge.EVENT_BUS.post(new PacketEvent.ReceiveEvent(packet))) ci.cancel(); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at PacketEvent.ReceiveEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + NetworkManagerHookKt.onReceivePacket(context, packet, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/neu/MixinCustomAH.java b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinCustomAH.java index 36830fb9..e87e2b7e 100644 --- a/src/main/java/skytils/skytilsmod/mixins/neu/MixinCustomAH.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinCustomAH.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.neu; +package skytils.skytilsmod.mixins.transformers.neu; import net.minecraft.client.gui.Gui; import org.spongepowered.asm.mixin.Dynamic; diff --git a/src/main/java/skytils/skytilsmod/mixins/neu/MixinGuiProfileViewer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinGuiProfileViewer.java index bd4b86f0..e47110cc 100644 --- a/src/main/java/skytils/skytilsmod/mixins/neu/MixinGuiProfileViewer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinGuiProfileViewer.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.neu; +package skytils.skytilsmod.mixins.transformers.neu; import net.minecraft.client.gui.GuiScreen; import net.minecraft.item.ItemStack; @@ -25,9 +25,7 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.NEUCompatibility; -import skytils.skytilsmod.utils.RenderUtil; +import skytils.skytilsmod.mixins.hooks.neu.GuiProfileViewerHookKt; @Pseudo @Mixin(targets = "io.github.moulberry.notenoughupdates.profileviewer.GuiProfileViewer", remap = false) @@ -36,18 +34,12 @@ public abstract class MixinGuiProfileViewer extends GuiScreen { @Dynamic @Redirect(method = "drawInvsPage", at = @At(value = "INVOKE", target = "Lio/github/moulberry/notenoughupdates/util/Utils;drawItemStack(Lnet/minecraft/item/ItemStack;II)V")) private void renderRarityOnInvPage(ItemStack stack, int x, int y) throws Throwable { - if (Skytils.config.showItemRarity) { - RenderUtil.renderRarity(stack, x, y); - } - NEUCompatibility.INSTANCE.getDrawItemStackMethod().invokeExact(stack, x, y); + GuiProfileViewerHookKt.renderRarityOnPage(stack, x, y); } @Dynamic @Redirect(method = "drawPetsPage", at = @At(value = "INVOKE", target = "Lio/github/moulberry/notenoughupdates/util/Utils;drawItemStack(Lnet/minecraft/item/ItemStack;II)V", ordinal = 0)) private void renderRarityOnPetsPage(ItemStack stack, int x, int y) throws Throwable { - if (Skytils.config.showItemRarity) { - RenderUtil.renderRarity(stack, x, y); - } - NEUCompatibility.INSTANCE.getDrawItemStackMethod().invokeExact(stack, x, y); + GuiProfileViewerHookKt.renderRarityOnPage(stack, x, y); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/neu/MixinStorageManager.java b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinStorageManager.java index af828740..babb743e 100644 --- a/src/main/java/skytils/skytilsmod/mixins/neu/MixinStorageManager.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinStorageManager.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.neu; +package skytils.skytilsmod.mixins.transformers.neu; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/skytils/skytilsmod/mixins/neu/MixinTradeWindow.java b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinTradeWindow.java index 1905288e..2c321745 100644 --- a/src/main/java/skytils/skytilsmod/mixins/neu/MixinTradeWindow.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/neu/MixinTradeWindow.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.neu; +package skytils.skytilsmod.mixins.transformers.neu; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java b/src/main/java/skytils/skytilsmod/mixins/transformers/patcher/MixinFontRendererHook.java index 806ffd51..c91fb0ca 100644 --- a/src/main/java/skytils/skytilsmod/mixins/patcher/MixinFontRendererHook.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/patcher/MixinFontRendererHook.java @@ -16,50 +16,23 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.patcher; +package skytils.skytilsmod.mixins.transformers.patcher; -import net.minecraft.client.gui.FontRenderer; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; - -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; +import skytils.skytilsmod.mixins.hooks.patcher.FontRendererHookHookKt; @Pseudo @Mixin(targets = "club.sk1er.patcher.hooks.FontRendererHook", remap = false) public class MixinFontRendererHook { - MethodHandle sbaOverridePatcher = null; - - @Dynamic - @Inject(method = "<init>", at = @At("RETURN")) - private void onCtor(FontRenderer fontRenderer, CallbackInfo ci) { - try { - Class<?> sbaClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.FontRendererHook"); - MethodType mt = MethodType.methodType(boolean.class, String.class); - sbaOverridePatcher = MethodHandles.publicLookup().findStatic(sbaClass, "shouldOverridePatcher", mt); - } catch (Throwable e) { - System.out.println("SBA override method not found."); - e.printStackTrace(); - } - } - @Dynamic @Inject(method = "renderStringAtPos", at = @At("HEAD"), cancellable = true) private void overridePatcherFontRendererHook(String text, boolean shadow, CallbackInfoReturnable<Boolean> cir) { - try { - if (sbaOverridePatcher != null && Skytils.config != null && Skytils.config.fixSbaChroma) { - if ((boolean) sbaOverridePatcher.invokeExact(text)) cir.setReturnValue(false); - } - } catch (Throwable e) { - e.printStackTrace(); - } + FontRendererHookHookKt.overridePatcherFontRendererHook(text, shadow, cir); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinBlockRendererDispatcher.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinBlockRendererDispatcher.java index 5462fff8..b2f2a9dd 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinBlockRendererDispatcher.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinBlockRendererDispatcher.java @@ -16,42 +16,24 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.BlockModelShapes; import net.minecraft.client.renderer.BlockRendererDispatcher; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.MinecraftForge; 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.CallbackInfoReturnable; -import skytils.skytilsmod.events.RenderBlockInWorldEvent; +import skytils.skytilsmod.mixins.hooks.renderer.BlockRendererDispatcherHookKt; @Mixin(BlockRendererDispatcher.class) public abstract class MixinBlockRendererDispatcher implements IResourceManagerReloadListener { - - @Shadow private BlockModelShapes blockModelShapes; - @Inject(method = "getModelFromBlockState", at = @At("RETURN"), cancellable = true) private void modifyGetModelFromBlockState(IBlockState state, IBlockAccess worldIn, BlockPos pos, CallbackInfoReturnable<IBakedModel> cir) { - try { - RenderBlockInWorldEvent event = new RenderBlockInWorldEvent(state, worldIn, pos); - MinecraftForge.EVENT_BUS.post(event); - if (event.state != state) { - cir.setReturnValue(this.blockModelShapes.getModelForState(event.state)); - } - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at RenderBlockInWorldEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - + BlockRendererDispatcherHookKt.modifyGetModelFromBlockState(this, state, worldIn, pos, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinEntityRenderer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinEntityRenderer.java index 8ad896f9..d9a896ca 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinEntityRenderer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinEntityRenderer.java @@ -16,60 +16,37 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import kotlin.collections.CollectionsKt; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.resources.IResourceManagerReloadListener; import net.minecraft.entity.Entity; -import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.world.World; 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.ModifyVariable; import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.renderer.EntityRendererHookKt; import java.util.List; @Mixin(EntityRenderer.class) public abstract class MixinEntityRenderer implements IResourceManagerReloadListener { - @Shadow private Minecraft mc; - @ModifyVariable(method = "getMouseOver", at = @At(value = "STORE")) private List<Entity> modifyInteractables(List<Entity> entityList) { - if (Utils.inSkyblock) { - if (!Utils.inDungeons && Skytils.config.hideCreeperVeilNearNPCs) { - List<EntityOtherPlayerMP> npcs = this.mc.theWorld.getPlayers(EntityOtherPlayerMP.class, p -> p.getUniqueID().version() == 2 && p.getHealth() == 20 && !p.isPlayerSleeping()); - CollectionsKt.removeAll(entityList, (entity -> { - if (entity instanceof EntityCreeper && entity.isInvisible()) { - final EntityCreeper creeper = (EntityCreeper) entity; - if (creeper.getMaxHealth() == 20 && creeper.getHealth() == 20 && creeper.getPowered()) { - return CollectionsKt.any(npcs, (npc -> npc.getDistanceSqToEntity(entity) <= 49)); - } - } - return false; - })); - } - } - return entityList; + return EntityRendererHookKt.modifyInteractables(entityList); } @Inject(method = "hurtCameraEffect", at = @At("HEAD"), cancellable = true) private void onHurtcam(float partialTicks, CallbackInfo ci) { - if (Utils.inSkyblock && Skytils.config.noHurtcam) ci.cancel(); + EntityRendererHookKt.onHurtcam(partialTicks, ci); } @Redirect(method = "updateLightmap", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getLastLightningBolt()I")) private int getLastLightningBolt(World world) { - if (Skytils.config.hideLightning && Utils.inSkyblock) return 0; - return world.getLastLightningBolt(); + return EntityRendererHookKt.getLastLightningBolt(world); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinInventoryEffectRenderer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinInventoryEffectRenderer.java index 4fa81320..1229841d 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinInventoryEffectRenderer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinInventoryEffectRenderer.java @@ -16,21 +16,19 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.renderer.InventoryEffectRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.mixins.gui.MixinGuiContainer; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.renderer.InventoryEffectRendererHookKt; +import skytils.skytilsmod.mixins.transformers.gui.MixinGuiContainer; @Mixin(InventoryEffectRenderer.class) public abstract class MixinInventoryEffectRenderer extends MixinGuiContainer { @ModifyVariable(method = "updateActivePotionEffects", at = @At("STORE"), ordinal = 0) private boolean noDisplayPotionEffects(boolean bool) { - if (Skytils.config.hidePotionEffects && Utils.inSkyblock) return false; - return bool; + return InventoryEffectRendererHookKt.noDisplayPotionEffects(bool); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerArmorBase.java index e91b0080..3ebf60c9 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerArmorBase.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerArmorBase.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.GlStateManager; @@ -31,10 +31,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.features.impl.handlers.GlintCustomizer; -import skytils.skytilsmod.utils.ItemUtil; +import skytils.skytilsmod.mixins.hooks.renderer.LayerArmorBaseHookKt; import skytils.skytilsmod.utils.Utils; -import skytils.skytilsmod.utils.graphics.colors.CustomColor; import static skytils.skytilsmod.Skytils.getMc; @@ -56,14 +54,14 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> implements LayerR @Inject(method = "doRenderLayer", at = @At("HEAD"), cancellable = true) private void onRenderAllArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { - if (Skytils.config.transparentArmorLayer == 0 && Utils.inSkyblock && entitylivingbaseIn == getMc().thePlayer) ci.cancel(); + if (Skytils.config.getTransparentArmorLayer() == 0 && Utils.inSkyblock && entitylivingbaseIn == getMc().thePlayer) ci.cancel(); } @Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemArmor;getColor(Lnet/minecraft/item/ItemStack;)I")) private void setAlpha(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 (Utils.inSkyblock && entitylivingbaseIn == getMc().thePlayer) { modifiedAlpha = true; - this.alpha = Skytils.config.transparentArmorLayer; + this.alpha = Skytils.config.getTransparentArmorLayer(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); } @@ -80,47 +78,6 @@ public abstract class MixinLayerArmorBase<T extends ModelBase> implements LayerR @Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/layers/LayerArmorBase;renderGlint(Lnet/minecraft/entity/EntityLivingBase;Lnet/minecraft/client/model/ModelBase;FFFFFFF)V"), cancellable = true) private void replaceArmorGlint(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 (Utils.inSkyblock) { - ItemStack itemstack = this.getCurrentArmor(entitylivingbaseIn, armorSlot); - String itemId = ItemUtil.getSkyBlockItemID(itemstack); - if (GlintCustomizer.glintColors.containsKey(itemId)) { - ci.cancel(); - CustomColor color = GlintCustomizer.glintColors.get(itemId); - - float f = (float)entitylivingbaseIn.ticksExisted + partialTicks; - this.renderer.bindTexture(ENCHANTED_ITEM_GLINT_RES); - GlStateManager.enableBlend(); - GlStateManager.depthFunc(514); - GlStateManager.depthMask(false); - float f1 = 0.5F; - GlStateManager.color(f1, f1, f1, 1.0F); - //GlintCustomizer.glintColors.get(itemId).applyColor(); - - for (int i = 0; i < 2; ++i) - { - GlStateManager.disableLighting(); - GlStateManager.blendFunc(768, 1); - float f2 = 0.76F; - //GlStateManager.color(0.5F * f2, 0.25F * f2, 0.8F * f2, 1.0F); - color.applyColor(); - GlStateManager.matrixMode(5890); - GlStateManager.loadIdentity(); - float f3 = 0.33333334F; - GlStateManager.scale(f3, f3, f3); - GlStateManager.rotate(30.0F - (float)i * 60.0F, 0.0F, 0.0F, 1.0F); - GlStateManager.translate(0.0F, f * (0.001F + (float)i * 0.003F) * 20.0F, 0.0F); - GlStateManager.matrixMode(5888); - this.getArmorModel(armorSlot).render(entitylivingbaseIn, p_177182_2_, p_177182_3_, p_177182_5_, p_177182_6_, p_177182_7_, scale); - } - - GlStateManager.matrixMode(5890); - GlStateManager.loadIdentity(); - GlStateManager.matrixMode(5888); - GlStateManager.enableLighting(); - GlStateManager.depthMask(true); - GlStateManager.depthFunc(515); - GlStateManager.disableBlend(); - } - } + LayerArmorBaseHookKt.replaceArmorGlint(this, renderer, entitylivingbaseIn, p_177182_2_, p_177182_3_, partialTicks, p_177182_5_, p_177182_6_, p_177182_7_, scale, armorSlot, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerCreeperCharge.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerCreeperCharge.java index c6d416dd..0d145d2d 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinLayerCreeperCharge.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerCreeperCharge.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge; import net.minecraft.client.renderer.entity.layers.LayerRenderer; @@ -25,11 +25,7 @@ import net.minecraft.util.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.SBInfo; -import skytils.skytilsmod.utils.Utils; - -import java.util.Objects; +import skytils.skytilsmod.mixins.hooks.renderer.LayerCreeperChargeHookKt; @Mixin(LayerCreeperCharge.class) public abstract class MixinLayerCreeperCharge implements LayerRenderer<EntityCreeper> { @@ -38,9 +34,6 @@ public abstract class MixinLayerCreeperCharge implements LayerRenderer<EntityCre @ModifyArg(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderCreeper;bindTexture(Lnet/minecraft/util/ResourceLocation;)V")) private ResourceLocation modifyChargedCreeperLayer(ResourceLocation res) { - if (Utils.inSkyblock && Skytils.config.moreVisibleGhosts && Objects.equals(SBInfo.INSTANCE.getMode(), "mining_3")) { - res = VISIBLE_CREEPER_ARMOR; - } - return res; + return LayerCreeperChargeHookKt.modifyChargedCreeperLayer(res); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerCustomHead.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerCustomHead.java new file mode 100644 index 00000000..0c58bb5b --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinLayerCustomHead.java @@ -0,0 +1,48 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.renderer; + +import net.minecraft.client.renderer.entity.layers.LayerCustomHead; +import net.minecraft.client.renderer.entity.layers.LayerRenderer; +import net.minecraft.entity.EntityLivingBase; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import skytils.skytilsmod.mixins.hooks.renderer.LayerCustomHeadHookKt; + +@Mixin(LayerCustomHead.class) +public abstract class MixinLayerCustomHead implements LayerRenderer<EntityLivingBase> { + + @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V", shift = At.Shift.AFTER), cancellable = true) + private void renderCustomHeadLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { + LayerCustomHeadHookKt.renderCustomHeadLayer(entity, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale, ci); + } + + @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;popMatrix()V")) + private void renderCustomHeadLayerPost(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { + LayerCustomHeadHookKt.renderCustomHeadLayerPost(entity, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale, ci); + } + + @Inject(method = "doRenderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V"), cancellable = true) + private void renderGlintOnSkull(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale, CallbackInfo ci) { + LayerCustomHeadHookKt.renderGlintOnSkull(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale, ci); + } + +} diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRender.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRender.java index d9a3b5b4..f3ee89d0 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRender.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRender.java @@ -16,44 +16,25 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLiving; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.Vec3; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.events.CheckRenderEntityEvent; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.renderer.RenderHookKt; @Mixin(Render.class) public abstract class MixinRender<T extends Entity> { @Inject(method = "renderEntityOnFire", at = @At("HEAD"), cancellable = true) private void removeEntityOnFire(Entity entity, double x, double y, double z, float partialTicks, CallbackInfo ci) { - if (Skytils.config.hideEntityFire && Utils.inSkyblock) { - ci.cancel(); - } + RenderHookKt.removeEntityOnFire(entity, x, y, z, partialTicks, ci); } @Inject(method = "renderLivingLabel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;translate(FFF)V", shift = At.Shift.AFTER)) private void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance, CallbackInfo ci) { - if (Skytils.config.lowerEndermanNametags && (str.contains("❤") || str.contains("Hits")) && (str.contains("Enderman") || str.contains("Zealot") || str.contains("Voidling") || str.contains("Voidgloom"))) { - EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; - Vec3 vec3 = new Vec3(entityIn.posX - player.posX, 0, entityIn.posZ - player.posZ); - vec3 = vec3.normalize(); - GlStateManager.translate(-vec3.xCoord, -1.5, -vec3.zCoord); - } + RenderHookKt.renderLivingLabel(entityIn, str, x, y, z, maxDistance, ci); } - } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderBat.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderBat.java index 513eb98f..76bec310 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderBat.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderBat.java @@ -16,33 +16,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderBat; import net.minecraft.entity.passive.EntityBat; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.features.impl.handlers.MayorInfo; -import skytils.skytilsmod.utils.Utils; - -import java.util.Objects; +import skytils.skytilsmod.mixins.hooks.renderer.RenderBatHookKt; @Mixin(RenderBat.class) public abstract class MixinRenderBat { @Inject(method = "preRenderCallback", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;scale(FFF)V", shift = At.Shift.AFTER)) private void preRender(EntityBat bat, float partialTicks, CallbackInfo ci) { - if (Utils.inDungeons && Skytils.config.biggerBatModels && - (Objects.equals(MayorInfo.INSTANCE.getCurrentMayor(), "Derpy") ? - Utils.equalsOneOf(bat.getMaxHealth(), 200, 800) : - Utils.equalsOneOf(bat.getMaxHealth(), 100, 400) - ) - ) { - GlStateManager.scale(3, 3, 3); - } + RenderBatHookKt.preRenderBat(bat, partialTicks, ci); } }
\ No newline at end of file diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderEntityItem.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderEntityItem.java index f24be282..14d6cd1b 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderEntityItem.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderEntityItem.java @@ -16,24 +16,20 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.entity.RenderEntityItem; import net.minecraft.entity.item.EntityItem; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.renderer.RenderEntityItemHookKt; @Mixin(RenderEntityItem.class) public abstract class MixinRenderEntityItem { @Inject(method = "doRender", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/GlStateManager.pushMatrix()V", shift = At.Shift.AFTER, ordinal = 1)) private void scaleItemDrop(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { - if (!Utils.inSkyblock) return; - float scale = Skytils.config.itemDropScale; - GlStateManager.scale(scale, scale, scale); + RenderEntityItemHookKt.scaleItemDrop(entity, x, y, z, entityYaw, partialTicks, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderItem.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderItem.java new file mode 100644 index 00000000..2d20cf72 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderItem.java @@ -0,0 +1,53 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.renderer; + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.resources.model.IBakedModel; +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import skytils.skytilsmod.mixins.hooks.renderer.RenderItemHookKt; + +@Mixin(RenderItem.class) +public abstract class MixinRenderItem { + @Inject(method = "renderItemIntoGUI", at = @At("HEAD")) + private void renderRarity(ItemStack stack, int x, int y, CallbackInfo ci) { + RenderItemHookKt.renderRarity(stack, x, y, ci); + } + + @Inject(method = "renderItemOverlayIntoGUI", at = @At("RETURN")) + private void renderItemOverlayPost(FontRenderer fr, ItemStack stack, int xPosition, int yPosition, String text, CallbackInfo ci) { + RenderItemHookKt.renderItemOverlayPost(fr, stack, xPosition, yPosition, text, ci); + } + + @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "net/minecraft/client/renderer/GlStateManager.scale(FFF)V", shift = At.Shift.AFTER)) + private void renderItemPre(ItemStack stack, IBakedModel model, CallbackInfo ci) { + RenderItemHookKt.renderItemPre(stack, model, ci); + } + + @Inject(method = "renderItem(Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/resources/model/IBakedModel;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderItem;renderEffect(Lnet/minecraft/client/resources/model/IBakedModel;)V", shift = At.Shift.BEFORE), cancellable = true) + private void modifyGlintRendering(ItemStack stack, IBakedModel model, CallbackInfo ci) { + RenderItemHookKt.modifyGlintRendering(stack, model, ci); + } + +} diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderLightningBolt.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderLightningBolt.java index 623b1693..92870186 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderLightningBolt.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderLightningBolt.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.renderer.entity.RenderLightningBolt; import net.minecraft.entity.effect.EntityLightningBolt; @@ -31,7 +31,7 @@ import skytils.skytilsmod.utils.Utils; public abstract class MixinRenderLightningBolt { @Inject(method = "doRender", at = @At("HEAD"), cancellable = true) private void onRenderLightning(EntityLightningBolt entity, double x, double y, double z, float entityYaw, float partialTicks, CallbackInfo ci) { - if (Skytils.config.hideLightning && Utils.inSkyblock) { + if (Skytils.config.getHideLightning() && Utils.inSkyblock) { ci.cancel(); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderManager.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderManager.java index f83a76a4..7b51fa38 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRenderManager.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRenderManager.java @@ -16,29 +16,21 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.culling.ICamera; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; -import net.minecraft.util.ChatComponentText; -import net.minecraftforge.common.MinecraftForge; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.events.CheckRenderEntityEvent; +import skytils.skytilsmod.mixins.hooks.renderer.RenderManagerHookKt; @Mixin(RenderManager.class) public class MixinRenderManager { @Inject(method = "shouldRender", at = @At("HEAD"), cancellable = true) private void shouldRender(Entity entityIn, ICamera camera, double camX, double camY, double camZ, CallbackInfoReturnable<Boolean> cir) { - try { - if (MinecraftForge.EVENT_BUS.post(new CheckRenderEntityEvent<>(entityIn, camera, camX, camY, camZ))) cir.setReturnValue(false); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at CheckRenderEntityEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } + RenderManagerHookKt.shouldRender(entityIn, camera, camX, camY, camZ, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRendererLivingEntity.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRendererLivingEntity.java index a3cc3276..ab54ee44 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinRendererLivingEntity.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinRendererLivingEntity.java @@ -16,23 +16,17 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.monster.EntityEnderman; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.features.impl.misc.SlayerFeatures; -import skytils.skytilsmod.utils.RenderUtilKt; -import skytils.skytilsmod.utils.Utils; - -import java.util.Objects; +import skytils.skytilsmod.mixins.hooks.renderer.RendererLivingEntityHookKt; @Mixin(RendererLivingEntity.class) public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> extends Render<T> { @@ -42,16 +36,6 @@ public abstract class MixinRendererLivingEntity<T extends EntityLivingBase> exte @Inject(method = "getColorMultiplier", at = @At("HEAD"), cancellable = true) private void setColorMultiplier(T entity, float lightBrightness, float partialTickTime, CallbackInfoReturnable<Integer> cir) { - if (Skytils.config.recolorSeraphBoss && Utils.inSkyblock && entity instanceof EntityEnderman) { - EntityEnderman e = (EntityEnderman) entity; - if (SlayerFeatures.Companion.getSlayerEntity() != e) return; - e.hurtTime = 0; - - if (SlayerFeatures.Companion.getYangGlyphEntity() != null || SlayerFeatures.Companion.getYangGlyph() != null) { - cir.setReturnValue(RenderUtilKt.withAlpha(Skytils.config.seraphBeaconPhaseColor, 169)); - } else if (SlayerFeatures.Companion.getSlayerNameEntity() != null && SlayerFeatures.Companion.getSlayerNameEntity().getCustomNameTag().endsWith("Hits")) { - cir.setReturnValue(RenderUtilKt.withAlpha(Skytils.config.seraphHitsPhaseColor, 169)); - } else cir.setReturnValue(RenderUtilKt.withAlpha(Skytils.config.seraphNormalPhaseColor, 169)); - } + RendererLivingEntityHookKt.setColorMultiplier(entity, lightBrightness, partialTickTime, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntityChestRenderer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntityChestRenderer.java index 745ab392..e14678b5 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntityChestRenderer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntityChestRenderer.java @@ -16,9 +16,8 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; -import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntityChestRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntityChest; @@ -26,25 +25,19 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.features.impl.dungeons.solvers.ThreeWeirdosSolver; -import skytils.skytilsmod.utils.RenderUtilKt; - -import java.awt.*; +import skytils.skytilsmod.mixins.hooks.renderer.TileEntityChestRendererHookKt; @Mixin(TileEntityChestRenderer.class) public abstract class MixinTileEntityChestRenderer extends TileEntitySpecialRenderer<TileEntityChest> { @Inject(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelChest;renderAll()V", shift = At.Shift.BEFORE)) private void setChestColor(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage, CallbackInfo ci) { - if (te.getPos().equals(ThreeWeirdosSolver.riddleChest)) { - RenderUtilKt.bindColor(Color.RED); - GlStateManager.disableTexture2D(); - } + TileEntityChestRendererHookKt.setChestColor(te, x, y, z, partialTicks, destroyStage, ci); } @Inject(method = "renderTileEntityAt", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelChest;renderAll()V", shift = At.Shift.AFTER)) private void setChestColorPost(TileEntityChest te, double x, double y, double z, float partialTicks, int destroyStage, CallbackInfo ci) { - GlStateManager.enableTexture2D(); + TileEntityChestRendererHookKt.setChestColorPost(te, x, y, z, partialTicks, destroyStage, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntityItemStackRenderer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntityItemStackRenderer.java index 4a2150dc..a97c50a4 100644 --- a/src/main/java/skytils/skytilsmod/mixins/renderer/MixinTileEntityItemStackRenderer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntityItemStackRenderer.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.renderer; +package skytils.skytilsmod.mixins.transformers.renderer; import net.minecraft.client.renderer.tileentity.TileEntityItemStackRenderer; import net.minecraft.item.ItemStack; @@ -24,18 +24,12 @@ import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; - -import static skytils.skytilsmod.Skytils.getMc; +import skytils.skytilsmod.mixins.hooks.renderer.TileEntityItemStackRendererHookKt; @Mixin(TileEntityItemStackRenderer.class) public abstract class MixinTileEntityItemStackRenderer { @Inject(method = "renderByItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;renderSkull(FFFLnet/minecraft/util/EnumFacing;FILcom/mojang/authlib/GameProfile;I)V")) private void fixGlintForSkulls(ItemStack itemStack, CallbackInfo ci) { - if (Utils.inSkyblock && Skytils.config.enchantGlintFix && itemStack.hasEffect()) { - Utils.lastRenderedSkullStack = itemStack; - Utils.lastRenderedSkullEntity = getMc().thePlayer; - } + TileEntityItemStackRendererHookKt.fixGlintForSkulls(itemStack, ci); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntitySkullRenderer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntitySkullRenderer.java new file mode 100644 index 00000000..14aa2a08 --- /dev/null +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/renderer/MixinTileEntitySkullRenderer.java @@ -0,0 +1,41 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package skytils.skytilsmod.mixins.transformers.renderer; + +import com.mojang.authlib.GameProfile; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntitySkull; +import net.minecraft.util.EnumFacing; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import skytils.skytilsmod.mixins.hooks.renderer.TileEntitySkullRendererHookKt; + + +@Mixin(TileEntitySkullRenderer.class) +public abstract class MixinTileEntitySkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull> { + @Inject(method = "renderSkull", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/model/ModelBase;render(Lnet/minecraft/entity/Entity;FFFFFF)V", shift = At.Shift.AFTER), locals = LocalCapture.CAPTURE_FAILSOFT) + private void addGlintToSkull(float x, float y, float z, EnumFacing face, float rotation, int type, GameProfile profile, int p_180543_8_, CallbackInfo ci, ModelBase model) { + TileEntitySkullRendererHookKt.addGlintToSkull(x, y, z, face, rotation, type, profile, p_180543_8_, ci, model); + } +} diff --git a/src/main/java/skytils/skytilsmod/mixins/util/MixinIChatComponent$Serializer.java b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinIChatComponent$Serializer.java index e682404e..4576c077 100644 --- a/src/main/java/skytils/skytilsmod/mixins/util/MixinIChatComponent$Serializer.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinIChatComponent$Serializer.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.util; +package skytils.skytilsmod.mixins.transformers.util; import com.google.gson.JsonDeserializer; import com.google.gson.JsonSerializer; @@ -25,14 +25,12 @@ import net.minecraft.util.IChatComponent; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; +import skytils.skytilsmod.mixins.hooks.util.IChatComponent_SerializerHookKt; @Mixin(IChatComponent.Serializer.class) public abstract class MixinIChatComponent$Serializer implements JsonDeserializer<IChatComponent>, JsonSerializer<IChatComponent> { @ModifyVariable(method = "serialize", at = @At("HEAD"), argsOnly = true) private IChatComponent fixUTextComponentSerialize(IChatComponent component) { - if (component instanceof UTextComponent) { - return ((UTextComponent)component).getComponent(); - } - return component; + return IChatComponent_SerializerHookKt.fixUTextComponentSerialize(component); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/util/MixinUtil.java b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinUtil.java index 43fc814f..4044dc97 100644 --- a/src/main/java/skytils/skytilsmod/mixins/util/MixinUtil.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/util/MixinUtil.java @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.util; +package skytils.skytilsmod.mixins.transformers.util; import net.minecraft.util.Util; import org.apache.logging.log4j.Logger; @@ -33,7 +33,7 @@ import java.util.concurrent.FutureTask; public abstract class MixinUtil { @Inject(method = "runTask", at = @At(value = "INVOKE", target = "Lorg/apache/logging/log4j/Logger;fatal(Ljava/lang/String;Ljava/lang/Throwable;)V", remap = false), cancellable = true) private static <V> void interceptTaskExceptions(FutureTask<V> task, Logger logger, CallbackInfoReturnable<V> cir) { - if (Skytils.config.preventLogSpam && Utils.isOnHypixel) { + if (Skytils.config.getPreventLogSpam() && Utils.isOnHypixel) { cir.setReturnValue(null); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/world/MixinChunk.java b/src/main/java/skytils/skytilsmod/mixins/transformers/world/MixinChunk.java index 5392e327..33cd4eb8 100644 --- a/src/main/java/skytils/skytilsmod/mixins/world/MixinChunk.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/world/MixinChunk.java @@ -16,21 +16,18 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.world; +package skytils.skytilsmod.mixins.transformers.world; import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; import net.minecraft.util.BlockPos; -import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.MinecraftForge; 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.CallbackInfoReturnable; -import skytils.skytilsmod.events.BlockChangeEvent; +import skytils.skytilsmod.mixins.hooks.world.ChunkHookKt; @Mixin(Chunk.class) public abstract class MixinChunk { @@ -41,15 +38,7 @@ public abstract class MixinChunk { @Inject(method = "setBlockState", at = @At("HEAD")) private void onBlockChange(BlockPos pos, IBlockState state, CallbackInfoReturnable<IBlockState> cir) { - IBlockState old = this.getBlockState(pos); - if (old != state) { - try { - MinecraftForge.EVENT_BUS.post(new BlockChangeEvent(pos, old, state)); - } catch (Throwable e) { - Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new ChatComponentText("§cSkytils caught and logged an exception at BlockChangeEvent. Please report this on the Discord server.")); - e.printStackTrace(); - } - } + ChunkHookKt.onBlockChange(this, pos, state, cir); } } diff --git a/src/main/java/skytils/skytilsmod/mixins/world/MixinWorld.java b/src/main/java/skytils/skytilsmod/mixins/transformers/world/MixinWorld.java index 6d2eec93..d123dbe5 100644 --- a/src/main/java/skytils/skytilsmod/mixins/world/MixinWorld.java +++ b/src/main/java/skytils/skytilsmod/mixins/transformers/world/MixinWorld.java @@ -16,21 +16,19 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.mixins.world; +package skytils.skytilsmod.mixins.transformers.world; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; -import skytils.skytilsmod.Skytils; -import skytils.skytilsmod.utils.Utils; +import skytils.skytilsmod.mixins.hooks.world.WorldHookKt; @Mixin(World.class) public abstract class MixinWorld implements IBlockAccess { @Redirect(method = "getSkyColorBody", at = @At(value = "FIELD", target = "Lnet/minecraft/world/World;lastLightningBolt:I")) private int lightningSkyColor(World world) { - if (Skytils.config.hideLightning && Utils.inSkyblock) return 0; - else return world.getLastLightningBolt(); + return WorldHookKt.lightningSkyColor(world); } } diff --git a/src/main/kotlin/skytils/skytilsmod/Skytils.kt b/src/main/kotlin/skytils/skytilsmod/Skytils.kt index ac93cc69..6fd70906 100644 --- a/src/main/kotlin/skytils/skytilsmod/Skytils.kt +++ b/src/main/kotlin/skytils/skytilsmod/Skytils.kt @@ -73,9 +73,9 @@ import skytils.skytilsmod.gui.OptionsGui import skytils.skytilsmod.gui.ReopenableGUI import skytils.skytilsmod.listeners.ChatListener import skytils.skytilsmod.listeners.DungeonListener -import skytils.skytilsmod.mixins.accessors.AccessorCommandHandler -import skytils.skytilsmod.mixins.accessors.AccessorGuiNewChat -import skytils.skytilsmod.mixins.accessors.AccessorSettingsGui +import skytils.skytilsmod.mixins.transformers.accessors.AccessorCommandHandler +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat +import skytils.skytilsmod.mixins.transformers.accessors.AccessorSettingsGui import skytils.skytilsmod.utils.* import skytils.skytilsmod.utils.graphics.ScreenRenderer import java.io.File diff --git a/src/main/kotlin/skytils/skytilsmod/core/Config.kt b/src/main/kotlin/skytils/skytilsmod/core/Config.kt index a0807707..ee2ec604 100644 --- a/src/main/kotlin/skytils/skytilsmod/core/Config.kt +++ b/src/main/kotlin/skytils/skytilsmod/core/Config.kt @@ -302,7 +302,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Increases the size of bat models.\nThe hitbox of the bat may be offset from what is shown.", category = "Dungeons", subcategory = "Quality of Life" ) - @JvmField var biggerBatModels = false @Property( @@ -399,7 +398,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Changes the color of the blaze to shoot on Higher or Lower.", category = "Dungeons", subcategory = "Solvers" ) - @JvmField var blazeSolver = false @Property( @@ -407,7 +405,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Colors the next blaze to shoot in Higher or Lower yellow.", category = "Dungeons", subcategory = "Solvers" ) - @JvmField var showNextBlaze = false @Property( @@ -415,7 +412,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Color used to highlight the lowest blaze in.", category = "Dungeons", subcategory = "Solvers" ) - @JvmField var lowestBlazeColor = Color(255, 0, 0, 200) @Property( @@ -423,7 +419,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Color used to highlight the highest blaze in.", category = "Dungeons", subcategory = "Solvers" ) - @JvmField var highestBlazeColor = Color(0, 255, 0, 200) @Property( @@ -431,7 +426,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Color used to highlight the next blaze in.", category = "Dungeons", subcategory = "Solvers" ) - @JvmField var nextBlazeColor = Color(255, 255, 0, 200) @Property( @@ -859,7 +853,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Makes ghosts more visible in the Dwarven Mines.\nThis is allowed on the Hypixel network and can be done in Vanilla.", category = "Mining", subcategory = "Quality of Life" ) - @JvmField var moreVisibleGhosts = false @Property( @@ -958,7 +951,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Fixes SBA chroma with Patcher 1.6", category = "Miscellaneous", subcategory = "Fixes" ) - @JvmField var fixSbaChroma = false /* @@ -981,7 +973,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Shortens item names with stars in them.", category = "Miscellaneous", subcategory = "Items" ) - @JvmField var compactStars = false @Property( @@ -1005,7 +996,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting maxF = 5f, decimalPlaces = 2 ) - @JvmField var itemDropScale = 1f @Property( @@ -1022,7 +1012,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting maxF = 2f, decimalPlaces = 2 ) - @JvmField var largerHeadScale = 1f @Property( @@ -1107,7 +1096,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Shows the rarity of an item in the color", category = "Miscellaneous", subcategory = "Item Rarity" ) - @JvmField var showItemRarity = false @Property( @@ -1192,7 +1180,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Changes the transparency of your armor layer.", category = "Miscellaneous", subcategory = "Other" ) - @JvmField var transparentArmorLayer = 1f @Property( @@ -1200,7 +1187,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Changes the transparency of your head layer.", category = "Miscellaneous", subcategory = "Other" ) - @JvmField var transparentHeadLayer = 1f /*@Property( @@ -1208,7 +1194,7 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "§c[WIP] §rChanges the summon's skin to the correct one.\n§cThis is very broken and may crash your game.", category = "Miscellaneous", subcategory = "Other" )*/ - @JvmField + var fixSummonSkin = false @Property( @@ -1216,7 +1202,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Uses the player's skin for necromancy mobs.", category = "Miscellaneous", subcategory = "Other" ) - @JvmField var usePlayerSkin = false @Property( @@ -1245,7 +1230,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Removes the vanilla effects of Night Vision.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var disableNightVision = false @Property( @@ -1261,7 +1245,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Fixes some items not having the enchantment glint.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var enchantGlintFix = false @Property( @@ -1276,7 +1259,7 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Stops the Creeper Veil from blocking interaction with NPCs.", category = "Miscellaneous", subcategory = "Quality of Life" )*/ - @JvmField + var hideCreeperVeilNearNPCs = false @Property( @@ -1291,7 +1274,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Prevents the game from rendering fire on burning entities.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var hideEntityFire = false @Property( @@ -1313,7 +1295,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Prevents all lightning from rendering.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var hideLightning = false @Property( @@ -1321,7 +1302,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Hides the smoke particles created when mobs die.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var hideDeathParticles = false @Property( @@ -1329,7 +1309,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Prevents the game from rendering the potion effects in inventories while in Skyblock.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var hidePotionEffects = false @Property( @@ -1365,7 +1344,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Allows you to move the action bar as if it were a Skytils HUD element.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var moveableActionBar = false @Property( @@ -1373,7 +1351,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Allows you to move the item name highlight as if it were a Skytils HUD element.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var moveableItemNameHighlight = false @Property( @@ -1388,7 +1365,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Removes the screen shake when you are hurt.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var noHurtcam = false @Property( @@ -1403,7 +1379,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Prevents your logs from being spammed with exceptions while on Hypixel.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var preventLogSpam = false /* @Property( @@ -1411,7 +1386,7 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Prioritize right click abilities over the profile viewer.\n§cThis feature is use at your own risk and may be removed later!", category = "Miscellaneous", subcategory = "Quality of Life" )*/ - @JvmField + var prioritizeItemAbilities = false // TODO get Sk1er LLC to make a number text box @@ -1490,7 +1465,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Lowers the health and nametag of endermen so it's easier to see.", category = "Miscellaneous", subcategory = "Quality of Life" ) - @JvmField var lowerEndermanNametags = false @Property( @@ -1665,7 +1639,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting description = "Changes the color of your Seraph boss based on the phase it is in.\nBeacon takes priority over the other colors.", category = "Slayer", subcategory = "Voidgloom Seraph" ) - @JvmField var recolorSeraphBoss = false @Property( @@ -1673,7 +1646,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting category = "Slayer", subcategory = "Voidgloom Seraph", allowAlpha = false ) - @JvmField var seraphBeaconPhaseColor = Color(255, 255, 255) @Property( @@ -1681,7 +1653,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting category = "Slayer", subcategory = "Voidgloom Seraph", allowAlpha = false ) - @JvmField var seraphHitsPhaseColor = Color(255, 255, 255) @Property( @@ -1689,7 +1660,6 @@ class Config : Vigilant(File("./config/skytils/config.toml"), "Skytils", sorting category = "Slayer", subcategory = "Voidgloom Seraph", allowAlpha = false ) - @JvmField var seraphNormalPhaseColor = Color(255, 255, 255) @Property( diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/events/MayorDiana.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/events/MayorDiana.kt index 34430d67..1f790624 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/events/MayorDiana.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/events/MayorDiana.kt @@ -32,7 +32,7 @@ import skytils.skytilsmod.Skytils import skytils.skytilsmod.Skytils.Companion.mc import skytils.skytilsmod.events.CheckRenderEntityEvent import skytils.skytilsmod.events.PacketEvent -import skytils.skytilsmod.mixins.accessors.AccessorMinecraft +import skytils.skytilsmod.mixins.transformers.accessors.AccessorMinecraft import skytils.skytilsmod.utils.RenderUtil import skytils.skytilsmod.utils.Utils import skytils.skytilsmod.utils.baseMaxHealth diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/SpamHider.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/SpamHider.kt index 38622117..6905cfbd 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/SpamHider.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/handlers/SpamHider.kt @@ -30,7 +30,7 @@ import skytils.skytilsmod.core.structure.FloatPair import skytils.skytilsmod.core.structure.GuiElement import skytils.skytilsmod.events.PacketEvent.ReceiveEvent import skytils.skytilsmod.events.SetActionBarEvent -import skytils.skytilsmod.mixins.accessors.AccessorGuiNewChat +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat import skytils.skytilsmod.utils.Utils import skytils.skytilsmod.utils.graphics.ScreenRenderer import skytils.skytilsmod.utils.graphics.SmartFontRenderer.TextAlignment diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/overlays/AuctionPriceOverlay.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/overlays/AuctionPriceOverlay.kt index bbb1af40..6be08deb 100644 --- a/src/main/kotlin/skytils/skytilsmod/features/impl/overlays/AuctionPriceOverlay.kt +++ b/src/main/kotlin/skytils/skytilsmod/features/impl/overlays/AuctionPriceOverlay.kt @@ -38,7 +38,7 @@ import skytils.skytilsmod.Skytils import skytils.skytilsmod.events.GuiContainerEvent.SlotClickEvent import skytils.skytilsmod.features.impl.handlers.AuctionData import skytils.skytilsmod.gui.elements.CleanButton -import skytils.skytilsmod.mixins.accessors.AccessorGuiEditSign +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiEditSign import skytils.skytilsmod.utils.ItemUtil import skytils.skytilsmod.utils.NumberUtil import skytils.skytilsmod.utils.SBInfo diff --git a/src/main/kotlin/skytils/skytilsmod/listeners/ChatListener.kt b/src/main/kotlin/skytils/skytilsmod/listeners/ChatListener.kt index 77421378..092fced4 100644 --- a/src/main/kotlin/skytils/skytilsmod/listeners/ChatListener.kt +++ b/src/main/kotlin/skytils/skytilsmod/listeners/ChatListener.kt @@ -27,7 +27,7 @@ import net.minecraftforge.fml.common.eventhandler.EventPriority import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import skytils.skytilsmod.Skytils import skytils.skytilsmod.commands.RepartyCommand -import skytils.skytilsmod.mixins.accessors.AccessorGuiNewChat +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat import skytils.skytilsmod.utils.Utils import java.util.regex.Pattern diff --git a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt b/src/main/kotlin/skytils/skytilsmod/mixins/SkytilsMixinPlugin.kt index dfdaa968..f01c688d 100644 --- a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsMixinPlugin.kt +++ b/src/main/kotlin/skytils/skytilsmod/mixins/SkytilsMixinPlugin.kt @@ -16,7 +16,7 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -package skytils.skytilsmod.tweaker +package skytils.skytilsmod.mixins import net.minecraft.launchwrapper.Launch import org.spongepowered.asm.lib.tree.ClassNode @@ -25,12 +25,13 @@ import org.spongepowered.asm.mixin.extensibility.IMixinInfo class SkytilsMixinPlugin : IMixinConfigPlugin { + val mixinPackage = "skytils.skytilsmod.mixins.transformers" var deobfEnvironment = false override fun onLoad(mixinPackage: String) { deobfEnvironment = Launch.blackboard.getOrDefault("fml.deobfuscatedEnvironment", false) as Boolean if (deobfEnvironment) { - println("We are in a deobfuscated environment, loading compatability mixins.") + println("We are in a deobfuscated environment, loading compatibility mixins.") } } @@ -39,11 +40,11 @@ class SkytilsMixinPlugin : IMixinConfigPlugin { } override fun shouldApplyMixin(targetClassName: String, mixinClassName: String): Boolean { - if (!mixinClassName.startsWith("skytils.skytilsmod.mixins")) { - println("Mixin $mixinClassName for $targetClassName is foreign, disabling.") + if (!mixinClassName.startsWith(mixinPackage)) { + println("Woah, how did mixin $mixinClassName for $targetClassName get here?") return false } - if (mixinClassName.startsWith("skytils.skytilsmod.mixins.deobfenv") && !deobfEnvironment) { + if (mixinClassName.startsWith("$mixinPackage.deobfenv") && !deobfEnvironment) { println("Mixin $mixinClassName is for a deobfuscated environment, disabling.") return false } diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/audio/SoundManagerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/audio/SoundManagerHook.kt new file mode 100644 index 00000000..aa8904d8 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/audio/SoundManagerHook.kt @@ -0,0 +1,41 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.audio + +import net.minecraft.client.audio.ISound +import net.minecraft.client.audio.SoundCategory +import net.minecraft.client.audio.SoundPoolEntry +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.utils.Utils + +fun bypassPlayerVolume( + sound: ISound, + entry: SoundPoolEntry, + category: SoundCategory, + cir: CallbackInfoReturnable<Float> +) { + if (Utils.shouldBypassVolume) cir.returnValue = 1f +} + +fun stopPlayingUnknownSounds(p_sound: ISound, ci: CallbackInfo) { + if (p_sound.soundLocation.resourcePath.isBlank() && Utils.isOnHypixel && Skytils.config.preventLogSpam) { + ci.cancel() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/AbstractClientPlayerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/AbstractClientPlayerHook.kt new file mode 100644 index 00000000..4973388d --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/AbstractClientPlayerHook.kt @@ -0,0 +1,114 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.entity + +import gg.essential.universal.UChat +import net.minecraft.client.Minecraft +import net.minecraft.client.entity.AbstractClientPlayer +import net.minecraft.entity.Entity +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.util.ResourceLocation +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.features.impl.misc.SummonSkins.skintextureMap +import skytils.skytilsmod.utils.NumberUtil.unformat +import skytils.skytilsmod.utils.Utils + +class AbstractClientPlayerHook(player: Any) { + + val that: AbstractClientPlayer + + init { + that = player as AbstractClientPlayer + } + + var correctSkin: ResourceLocation? = null + val isSummonMob: Boolean by lazy { + if (!Utils.inSkyblock) return@lazy false + try { + if (that.name == "Lost Adventurer") { + val textures = that.gameProfile.properties["textures"].firstOrNull() + if (textures != null) { + return@lazy phoenixSkinObject == textures.value + } + } + } catch (e: Exception) { + return@lazy false + } + return@lazy false + } + + val summonType: String? by lazy { + if (!isSummonMob) return@lazy null + if (mc.theWorld == null) return@lazy null + val nearbyEntities = Minecraft.getMinecraft().theWorld.getEntitiesInAABBexcluding( + that, + that.entityBoundingBox.expand(0.0, 1.0, 0.0) + ) { entity: Entity? -> entity is EntityArmorStand && entity.hasCustomName() } + for (entity in nearbyEntities) { + val name = entity.customNameTag + if (!(name.contains("'s ") && name.contains("§c❤"))) continue + val parsedHealth = unformat(name.substringAfter(" §a").substringBefore("§c❤")) + if (parsedHealth.toFloat() != that.health) continue + return@lazy name.substringAfter("'s ").substringBefore(" §").replace(" ", "") + .lowercase() + } + return@lazy null + } + + fun replaceSkin(cir: CallbackInfoReturnable<ResourceLocation?>) { + if (isSummonMob) { + if (Skytils.config.fixSummonSkin) { + if (correctSkin == null) { + if (summonType == "lostadventurer") { + return + } + // TODO Add support for resource packs + correctSkin = try { + skintextureMap[summonType]!!.resource + } catch (npe: NullPointerException) { + UChat.chat( + "§cPlease tell Skytils dev to add a skin for $summonType" + ) + if (Skytils.config.usePlayerSkin || Utils.noSychic) mc.thePlayer.locationSkin else sychicSkin + } + } + cir.setReturnValue(correctSkin) + } else { + cir.setReturnValue(if (Skytils.config.usePlayerSkin || Utils.noSychic) mc.thePlayer.locationSkin else sychicSkin) + } + } + } + + fun replaceHasSkin(cir: CallbackInfoReturnable<Boolean>) { + if (isSummonMob) cir.returnValue = true + } + + fun replaceSkinType(cir: CallbackInfoReturnable<String>) { + if (isSummonMob) cir.returnValue = + if (Skytils.config.usePlayerSkin || Utils.noSychic) mc.thePlayer.skinType else "slim" + } + + companion object { + val sychicSkin = ResourceLocation("skytils:sychicskin.png") + + val phoenixSkinObject = + "eyJ0aW1lc3RhbXAiOjE1NzU0NzAyNzE3MTUsInByb2ZpbGVJZCI6ImRlNTcxYTEwMmNiODQ4ODA4ZmU3YzlmNDQ5NmVjZGFkIiwicHJvZmlsZU5hbWUiOiJNSEZfTWluZXNraW4iLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzM2YTAzODNhNTI3ODAzZDk5YjY2MmFkMThiY2FjNzhjMTE5MjUwZWJiZmIxNDQ3NWI0ZWI0ZDRhNjYyNzk2YjQifX19" + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/BossStatusHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/BossStatusHook.kt new file mode 100644 index 00000000..2d79f1d5 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/BossStatusHook.kt @@ -0,0 +1,35 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.entity + +import net.minecraft.client.Minecraft +import net.minecraft.entity.boss.IBossDisplayData +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.events.BossBarEvent + + +fun onSetBossStatus(displayData: IBossDisplayData, hasColorModifierIn: Boolean, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post(BossBarEvent.Set(displayData, hasColorModifierIn))) ci.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at BossBarEvent.Set. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityBlazeHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityBlazeHook.kt new file mode 100644 index 00000000..aa63cc64 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityBlazeHook.kt @@ -0,0 +1,38 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.entity + +import net.minecraft.util.EnumParticleTypes +import net.minecraft.world.World +import skytils.skytilsmod.utils.Utils + +fun removeBlazeSmokeParticle( + world: World, + particleType: EnumParticleTypes, + xCoord: Double, + yCoord: Double, + zCoord: Double, + xOffset: Double, + yOffset: Double, + zOffset: Double, + p_175688_14_: IntArray +) { + if (particleType != EnumParticleTypes.SMOKE_LARGE || !Utils.inDungeons) { + world.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, *p_175688_14_) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityLivingBaseHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityLivingBaseHook.kt new file mode 100644 index 00000000..d0f941e0 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityLivingBaseHook.kt @@ -0,0 +1,59 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.entity + +import skytils.skytilsmod.Skytils +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import net.minecraft.world.World +import net.minecraft.util.EnumParticleTypes +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.Entity +import net.minecraft.potion.Potion +import org.spongepowered.asm.mixin.Mixin +import org.spongepowered.asm.mixin.injection.* +import skytils.skytilsmod.utils.* + +fun modifyPotionActive(potion: Potion, cir: CallbackInfoReturnable<Boolean>) { + if (!Utils.inSkyblock) return + if (Skytils.config.disableNightVision && potion === Potion.nightVision) { + cir.returnValue = false + } +} + +fun modifyPotionActive(potionId: Int, cir: CallbackInfoReturnable<Boolean>) { + if (!Utils.inSkyblock) return + if (Skytils.config.disableNightVision && potionId == Potion.nightVision.id) { + cir.returnValue = false + } +} + +fun removeDeathParticle( + world: World, + particleType: EnumParticleTypes, + xCoord: Double, + yCoord: Double, + zCoord: Double, + xOffset: Double, + yOffset: Double, + zOffset: Double, + p_175688_14_: IntArray +) { + if (!(Skytils.config.hideDeathParticles && particleType == EnumParticleTypes.EXPLOSION_NORMAL)) { + world.spawnParticle(particleType, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, *p_175688_14_) + } +} diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityPlayerSPHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityPlayerSPHook.kt new file mode 100644 index 00000000..5b98d8b6 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/entity/EntityPlayerSPHook.kt @@ -0,0 +1,47 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.entity + +import net.minecraft.entity.item.EntityItem +import net.minecraft.util.ChatComponentText +import net.minecraft.util.IChatComponent +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.events.AddChatMessageEvent +import skytils.skytilsmod.events.ItemTossEvent + +fun onAddChatMessage(message: IChatComponent, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post(AddChatMessageEvent(message))) ci.cancel() + } catch (e: Throwable) { + mc.ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at AddChatMessageEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +} + +fun onDropItem(dropAll: Boolean, cir: CallbackInfoReturnable<EntityItem?>) { + try { + val stack = mc.thePlayer.inventory.getCurrentItem() + if (stack != null && MinecraftForge.EVENT_BUS.post(ItemTossEvent(stack, dropAll))) cir.returnValue = null + } catch (e: Throwable) { + mc.ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at PlayerDropItemEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/forge/SplashProgressHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/forge/SplashProgressHook.kt new file mode 100644 index 00000000..c07b9a6c --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/forge/SplashProgressHook.kt @@ -0,0 +1,26 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.forge + +import net.minecraft.util.ResourceLocation +import skytils.skytilsmod.utils.Utils + + +fun setForgeGif(resourceLocation: ResourceLocation): ResourceLocation { + return if (Utils.noSychic) resourceLocation else ResourceLocation("skytils", "sychicpet.gif") +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiContainerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiContainerHook.kt new file mode 100644 index 00000000..560fa056 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiContainerHook.kt @@ -0,0 +1,107 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.gui + +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.inventory.GuiContainer +import net.minecraft.inventory.Slot +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.events.GuiContainerEvent +import skytils.skytilsmod.events.GuiContainerEvent.CloseWindowEvent +import skytils.skytilsmod.events.GuiContainerEvent.SlotClickEvent + +class GuiContainerHook(guiAny: Any) { + + val gui: GuiContainer + + init { + gui = guiAny as GuiContainer + } + + fun closeWindowPressed(ci: CallbackInfo) { + try { + MinecraftForge.EVENT_BUS.post(CloseWindowEvent(gui, gui.inventorySlots)) + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.CloseWindowEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + } + + fun backgroundDrawn(mouseX: Int, mouseY: Int, partialTicks: Float, ci: CallbackInfo) { + try { + MinecraftForge.EVENT_BUS.post( + GuiContainerEvent.BackgroundDrawnEvent( + gui, + gui.inventorySlots, + mouseX, + mouseY, + partialTicks + ) + ) + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.BackgroundDrawnEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + } + + fun onDrawSlot(slot: Slot, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post( + GuiContainerEvent.DrawSlotEvent.Pre( + gui, + gui.inventorySlots, + slot + ) + ) + ) ci.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.DrawSlotEvent.Pre. Please report this on the Discord server.")) + e.printStackTrace() + } + } + + fun onDrawSlotPost(slot: Slot, ci: CallbackInfo) { + try { + MinecraftForge.EVENT_BUS.post(GuiContainerEvent.DrawSlotEvent.Post(gui, gui.inventorySlots, slot)) + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.DrawSlotEvent.Post. Please report this on the Discord server.")) + e.printStackTrace() + } + } + + fun onMouseClick(slot: Slot, slotId: Int, clickedButton: Int, clickType: Int, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post( + SlotClickEvent( + gui, + gui.inventorySlots, + slot, + slotId, + clickedButton, + clickType + ) + ) + ) ci.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiContainerEvent.SlotClickEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameForgeHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameForgeHook.kt new file mode 100644 index 00000000..49364db7 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameForgeHook.kt @@ -0,0 +1,45 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.gui + +import net.minecraft.item.ItemStack +import org.spongepowered.asm.mixin.injection.invoke.arg.Args +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.core.structure.GuiElement +import skytils.skytilsmod.features.impl.misc.MiscFeatures +import skytils.skytilsmod.utils.* + +fun modifyItemHighlightPosition(args: Args, highlightingItemStack: ItemStack) { + if (Skytils.config.moveableItemNameHighlight && Utils.inSkyblock) { + val fr = highlightingItemStack.item.getFontRenderer(highlightingItemStack) ?: mc.fontRendererObj + val itemName = args.get<String>(0) + val element: GuiElement = MiscFeatures.ItemNameHighlightDummy + val x = element.actualX - fr!!.getStringWidth(itemName) / 2f + args.set(1, x) + args.set(2, element.actualY) + } +} + +fun modifyActionBarPosition(args: Args) { + if (Skytils.config.moveableActionBar && Utils.inSkyblock) { + val element: GuiElement = MiscFeatures.ActionBarDummy + args.set(0, element.actualX) + args.set(1, element.actualY + 4f) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameHook.kt new file mode 100644 index 00000000..d1df2976 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiIngameHook.kt @@ -0,0 +1,67 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.gui + +import net.minecraft.client.Minecraft +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.events.SetActionBarEvent +import skytils.skytilsmod.utils.RenderUtil.renderRarity +import skytils.skytilsmod.utils.Utils + + +var recordPlaying: String? = null +var recordPlayingUpFor: Int = 0 +var recordIsPlaying: Boolean = false + +fun onSetActionBar(message: String, isPlaying: Boolean, ci: CallbackInfo): Boolean { + try { + val event = SetActionBarEvent(message, isPlaying) + if (MinecraftForge.EVENT_BUS.post(event)) { + ci.cancel() + return false + } + if (message != event.message || isPlaying != event.isPlaying) { + ci.cancel() + recordPlaying = event.message + recordPlayingUpFor = 60 + recordIsPlaying = event.isPlaying + return true + } + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at SetActionBarEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + return false +} + +fun renderRarityOnHotbar( + index: Int, + xPos: Int, + yPos: Int, + partialTicks: Float, + player: EntityPlayer, + ci: CallbackInfo +) { + if (Utils.inSkyblock && Skytils.config.showItemRarity) { + renderRarity(player.inventory.mainInventory[index], xPos, yPos) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiScreenHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiScreenHook.kt new file mode 100644 index 00000000..38924ee2 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/gui/GuiScreenHook.kt @@ -0,0 +1,36 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.gui + +import net.minecraft.client.Minecraft +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.events.SendChatMessageEvent + +fun onSendChatMessage(message: String, addToChat: Boolean, ci: CallbackInfo) { + try { + val event = SendChatMessageEvent(message, addToChat) + if (MinecraftForge.EVENT_BUS.post(event)) { + ci.cancel() + } + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at SendChatMessageEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt new file mode 100644 index 00000000..f2c053e8 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/inventory/SlotHook.kt @@ -0,0 +1,49 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.inventory + +import net.minecraft.inventory.Slot +import net.minecraft.item.ItemStack +import net.minecraft.nbt.NBTTagCompound +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.SelectAllColorSolver +import skytils.skytilsmod.features.impl.dungeons.solvers.terminals.StartsWithSequenceSolver +import skytils.skytilsmod.utils.Utils + +class SlotHook(slotC: Any) { + val slot: Slot + + init { + slot = slotC as Slot + } + + fun markTerminalItems(cir: CallbackInfoReturnable<ItemStack?>) { + if (!Utils.inSkyblock) return + val item: ItemStack = (slot.inventory.getStackInSlot(slot.slotIndex) ?: return).copy() + if (!item.isItemEnchanted && (SelectAllColorSolver.shouldClick.contains(slot.slotNumber) || StartsWithSequenceSolver.shouldClick.contains( + slot.slotNumber + )) + ) { + if (item.tagCompound == null) { + item.tagCompound = NBTTagCompound() + } + item.tagCompound.setBoolean("SkytilsForceGlint", true) + cir.returnValue = item + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemArmorHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemArmorHook.kt new file mode 100644 index 00000000..ebfa7851 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemArmorHook.kt @@ -0,0 +1,46 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.item + +import net.minecraft.item.ItemStack +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.features.impl.handlers.ArmorColor +import skytils.skytilsmod.utils.ItemUtil.getExtraAttributes +import skytils.skytilsmod.utils.Utils + +fun replaceArmorColor(stack: ItemStack, cir: CallbackInfoReturnable<Int>) { + if (!Utils.inSkyblock) return + val extraAttributes = getExtraAttributes(stack) + if (extraAttributes != null && extraAttributes.hasKey("uuid")) { + val uuid = extraAttributes.getString("uuid") + if (ArmorColor.armorColors.containsKey(uuid)) { + cir.returnValue = ArmorColor.armorColors[uuid]!!.toInt() + } + } +} + +fun hasCustomArmorColor(stack: ItemStack, cir: CallbackInfoReturnable<Boolean>) { + if (!Utils.inSkyblock) return + val extraAttributes = getExtraAttributes(stack) + if (extraAttributes != null && extraAttributes.hasKey("uuid")) { + val uuid = extraAttributes.getString("uuid") + if (ArmorColor.armorColors.containsKey(uuid)) { + cir.returnValue = true + } + } +} diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemStackHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemStackHook.kt new file mode 100644 index 00000000..46d6215b --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/item/ItemStackHook.kt @@ -0,0 +1,72 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.item + +import net.minecraft.item.ItemStack +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.features.impl.handlers.GlintCustomizer +import skytils.skytilsmod.utils.ItemUtil.getExtraAttributes +import skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID +import skytils.skytilsmod.utils.Utils +import skytils.skytilsmod.utils.countMatches + +const val starPattern = "§6✪" +const val masterStarPattern = "§c✪" + +fun showEnchantmentGlint(stack: Any, cir: CallbackInfoReturnable<Boolean>) { + (stack as ItemStack).apply { + if (!Utils.inSkyblock) return + val extraAttr = getExtraAttributes(this) + if (extraAttr != null) { + val itemId = getSkyBlockItemID(extraAttr) + if (GlintCustomizer.overrides.containsKey(itemId)) { + cir.returnValue = GlintCustomizer.overrides[itemId] + return + } + if (Skytils.config.enchantGlintFix) { + if (extraAttr.hasKey("enchantments") && extraAttr.getCompoundTag("enchantments").keySet.isNotEmpty()) { + cir.returnValue = true + return + } + } + } + if (tagCompound != null && tagCompound.hasKey("SkytilsForceGlint")) { + cir.returnValue = tagCompound.getBoolean("SkytilsForceGlint") + } + } +} + +fun modifyDisplayName(s: String): String { + var displayName = s + if (!Utils.inSkyblock) return displayName + try { + if (Skytils.config.compactStars && displayName.contains("✪")) { + if (displayName.contains("§c✪")) { + displayName = "${ + displayName.replace(starPattern, "") + .replace(masterStarPattern, "") + }§c${displayName.countMatches(masterStarPattern) + 5}✪" + } else { + displayName = "${displayName.replace(starPattern, "")}§6${displayName.countMatches(starPattern)}✪" + } + } + } catch (ignored: Exception) { + } + return displayName +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/model/ModelBlazeHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/model/ModelBlazeHook.kt new file mode 100644 index 00000000..b85c0b4c --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/model/ModelBlazeHook.kt @@ -0,0 +1,70 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.model + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.Entity +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.features.impl.dungeons.solvers.BlazeSolver +import skytils.skytilsmod.utils.bindColor + +fun changeBlazeColor( + entity: Entity, + p_78088_2_: Float, + p_78088_3_: Float, + p_78088_4_: Float, + p_78088_5_: Float, + p_78088_6_: Float, + scale: Float, + ci: CallbackInfo +) { + if (BlazeSolver.orderedBlazes.size == 0) return + GlStateManager.disableTexture2D() + GlStateManager.enableBlend() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + if (BlazeSolver.blazeMode <= 0) { + if (entity == BlazeSolver.orderedBlazes[0].blaze) { + Skytils.config.lowestBlazeColor.bindColor() + } else if (Skytils.config.showNextBlaze && BlazeSolver.blazeMode != 0 && BlazeSolver.orderedBlazes.size > 1 && entity == BlazeSolver.orderedBlazes[1].blaze) { + Skytils.config.nextBlazeColor.bindColor() + } + } + if (BlazeSolver.blazeMode >= 0) { + if (entity == BlazeSolver.orderedBlazes[BlazeSolver.orderedBlazes.size - 1].blaze) { + Skytils.config.highestBlazeColor.bindColor() + } else if (Skytils.config.showNextBlaze && BlazeSolver.blazeMode != 0 && BlazeSolver.orderedBlazes.size > 1 && entity == BlazeSolver.orderedBlazes[BlazeSolver.orderedBlazes.size - 2].blaze) { + val color = Skytils.config.nextBlazeColor + color.bindColor() + } + } +} + +fun renderModelBlazePost( + entityIn: Entity, + p_78088_2_: Float, + p_78088_3_: Float, + p_78088_4_: Float, + p_78088_5_: Float, + p_78088_6_: Float, + scale: Float, + ci: CallbackInfo +) { + GlStateManager.disableBlend() + GlStateManager.enableTexture2D() +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/multiplayer/PlayerControllerMPHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/multiplayer/PlayerControllerMPHook.kt new file mode 100644 index 00000000..350f7063 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/multiplayer/PlayerControllerMPHook.kt @@ -0,0 +1,59 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.multiplayer + +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.player.EntityPlayer +import net.minecraft.util.BlockPos +import net.minecraft.util.ChatComponentText +import net.minecraft.util.EnumFacing +import net.minecraft.util.MovingObjectPosition +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.At +import org.spongepowered.asm.mixin.injection.Inject +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.events.DamageBlockEvent +import skytils.skytilsmod.utils.ItemUtil.hasRightClickAbility +import skytils.skytilsmod.utils.Utils + +fun handleRightClickEntity( + player: EntityPlayer, + target: Entity, + movingObject: MovingObjectPosition?, + cir: CallbackInfoReturnable<Boolean> +) { + if (!Skytils.config.prioritizeItemAbilities || !Utils.inSkyblock || Utils.inDungeons) return + val item = player.heldItem + if (item != null && target !is EntityArmorStand) { + if (hasRightClickAbility(item)) { + cir.returnValue = false + } + } +} + +fun onPlayerDamageBlock(pos: BlockPos, directionFacing: EnumFacing, cir: CallbackInfoReturnable<Boolean>) { + try { + if (MinecraftForge.EVENT_BUS.post(DamageBlockEvent(pos, directionFacing))) cir.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at DamageBlockEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetHandlerPlayClientHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetHandlerPlayClientHook.kt new file mode 100644 index 00000000..8469e37f --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetHandlerPlayClientHook.kt @@ -0,0 +1,34 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.network + +import net.minecraft.client.Minecraft +import net.minecraft.network.Packet +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.events.PacketEvent.SendEvent + +fun onSendPacket(packet: Packet<*>, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post(SendEvent(packet))) ci.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at PacketEvent.SendEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetworkManagerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetworkManagerHook.kt new file mode 100644 index 00000000..80940c24 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/network/NetworkManagerHook.kt @@ -0,0 +1,35 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.network + +import io.netty.channel.ChannelHandlerContext +import net.minecraft.client.Minecraft +import net.minecraft.network.Packet +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.events.PacketEvent.ReceiveEvent + +fun onReceivePacket(context: ChannelHandlerContext, packet: Packet<*>, ci: CallbackInfo) { + try { + if (MinecraftForge.EVENT_BUS.post(ReceiveEvent(packet))) ci.cancel() + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at PacketEvent.ReceiveEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/neu/GuiProfileViewerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/neu/GuiProfileViewerHook.kt new file mode 100644 index 00000000..0832c0a0 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/neu/GuiProfileViewerHook.kt @@ -0,0 +1,30 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.neu + +import net.minecraft.item.ItemStack +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.utils.NEUCompatibility.drawItemStackMethod +import skytils.skytilsmod.utils.RenderUtil.renderRarity + +fun renderRarityOnPage(stack: ItemStack, x: Int, y: Int) { + if (Skytils.config.showItemRarity) { + renderRarity(stack, x, y) + } + drawItemStackMethod.invokeExact(stack, x, y) +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/patcher/FontRendererHookHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/patcher/FontRendererHookHook.kt new file mode 100644 index 00000000..6ee77dc3 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/patcher/FontRendererHookHook.kt @@ -0,0 +1,46 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.patcher + +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.Skytils +import java.lang.invoke.MethodHandle +import java.lang.invoke.MethodHandles +import java.lang.invoke.MethodType + +val sbaOverridePatcher: MethodHandle? by lazy { + try { + val sbaClass = Class.forName("codes.biscuit.skyblockaddons.asm.hooks.FontRendererHook") + val mt = MethodType.methodType(Boolean::class.javaPrimitiveType, String::class.java) + return@lazy MethodHandles.publicLookup().findStatic(sbaClass, "shouldOverridePatcher", mt) + } catch (e: Throwable) { + println("SBA override method not found.") + e.printStackTrace() + } + return@lazy null +} + +fun overridePatcherFontRendererHook(text: String, shadow: Boolean, cir: CallbackInfoReturnable<Boolean>) { + try { + if (sbaOverridePatcher != null && Skytils.config != null && Skytils.config.fixSbaChroma) { + if (sbaOverridePatcher!!.invokeExact(text) as Boolean) cir.returnValue = false + } + } catch (e: Throwable) { + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/BlockRendererDispatcherHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/BlockRendererDispatcherHook.kt new file mode 100644 index 00000000..77189de3 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/BlockRendererDispatcherHook.kt @@ -0,0 +1,50 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.block.state.IBlockState +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.BlockRendererDispatcher +import net.minecraft.client.resources.model.IBakedModel +import net.minecraft.util.BlockPos +import net.minecraft.util.ChatComponentText +import net.minecraft.world.IBlockAccess +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.events.RenderBlockInWorldEvent + +fun modifyGetModelFromBlockState( + blockRendererDispatcher: Any, + state: IBlockState, + worldIn: IBlockAccess, + pos: BlockPos, + cir: CallbackInfoReturnable<IBakedModel> +) { + (blockRendererDispatcher as BlockRendererDispatcher).apply { + try { + val event = RenderBlockInWorldEvent(state, worldIn, pos) + MinecraftForge.EVENT_BUS.post(event) + if (event.state !== state) { + cir.returnValue = blockModelShapes.getModelForState(event.state) + } + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at RenderBlockInWorldEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/EntityRendererHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/EntityRendererHook.kt new file mode 100644 index 00000000..3f06d172 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/EntityRendererHook.kt @@ -0,0 +1,56 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.entity.Entity +import net.minecraft.entity.monster.EntityCreeper +import net.minecraft.world.World +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.utils.Utils + +fun modifyInteractables(entityList: List<Entity>): List<Entity> { + entityList as ArrayList<Entity> + if (Utils.inSkyblock) { + if (!Utils.inDungeons && Skytils.config.hideCreeperVeilNearNPCs) { + val npcs = mc.theWorld.getPlayers( + EntityOtherPlayerMP::class.java + ) { p: EntityOtherPlayerMP? -> p!!.uniqueID.version() == 2 && p.health == 20f && !p.isPlayerSleeping } + entityList.removeAll label@{ entity: Entity -> + if (entity is EntityCreeper && entity.isInvisible()) { + val creeper = entity + if (creeper.maxHealth == 20f && creeper.health == 20f && creeper.powered) { + return@label npcs.any { npc: EntityOtherPlayerMP -> npc.getDistanceSqToEntity(entity) <= 49 } + } + } + false + } + } + } + return entityList +} + +fun onHurtcam(partialTicks: Float, ci: CallbackInfo) { + if (Utils.inSkyblock && Skytils.config.noHurtcam) ci.cancel() +} + +fun getLastLightningBolt(world: World): Int { + return if (Skytils.config.hideLightning && Utils.inSkyblock) 0 else world.lastLightningBolt +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/InventoryEffectRendererHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/InventoryEffectRendererHook.kt new file mode 100644 index 00000000..ef10446e --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/InventoryEffectRendererHook.kt @@ -0,0 +1,25 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.utils.Utils + +fun noDisplayPotionEffects(bool: Boolean): Boolean { + return if (Skytils.config.hidePotionEffects && Utils.inSkyblock) false else bool +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerArmorBaseHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerArmorBaseHook.kt new file mode 100644 index 00000000..e945d7cd --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerArmorBaseHook.kt @@ -0,0 +1,95 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.renderer.entity.RendererLivingEntity +import net.minecraft.client.renderer.entity.layers.LayerArmorBase +import net.minecraft.entity.EntityLivingBase +import net.minecraft.util.ResourceLocation +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.features.impl.handlers.GlintCustomizer +import skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID +import skytils.skytilsmod.utils.Utils + +private val ENCHANTED_ITEM_GLINT_RES = ResourceLocation("textures/misc/enchanted_item_glint.png") + + +fun replaceArmorGlint( + layerArmorBase: Any, + rendererLivingEntity: RendererLivingEntity<*>, + entitylivingbaseIn: EntityLivingBase, + p_177182_2_: Float, + p_177182_3_: Float, + partialTicks: Float, + p_177182_5_: Float, + p_177182_6_: Float, + p_177182_7_: Float, + scale: Float, + armorSlot: Int, + ci: CallbackInfo +) { + (layerArmorBase as LayerArmorBase<*>).apply { + if (Utils.inSkyblock) { + val itemstack = entitylivingbaseIn.getCurrentArmor(armorSlot - 1) + val itemId = getSkyBlockItemID(itemstack) + if (GlintCustomizer.glintColors.containsKey(itemId)) { + ci.cancel() + val color = GlintCustomizer.glintColors[itemId] + val f = entitylivingbaseIn.ticksExisted.toFloat() + partialTicks + rendererLivingEntity.bindTexture(ENCHANTED_ITEM_GLINT_RES) + GlStateManager.enableBlend() + GlStateManager.depthFunc(514) + GlStateManager.depthMask(false) + val f1 = 0.5f + GlStateManager.color(f1, f1, f1, 1.0f) + //GlintCustomizer.glintColors.get(itemId).applyColor(); + for (i in 0..1) { + GlStateManager.disableLighting() + GlStateManager.blendFunc(768, 1) + val f2 = 0.76f + //GlStateManager.color(0.5F * f2, 0.25F * f2, 0.8F * f2, 1.0F); + color!!.applyColor() + GlStateManager.matrixMode(5890) + GlStateManager.loadIdentity() + val f3 = 0.33333334f + GlStateManager.scale(f3, f3, f3) + GlStateManager.rotate(30.0f - i.toFloat() * 60.0f, 0.0f, 0.0f, 1.0f) + GlStateManager.translate(0.0f, f * (0.001f + i.toFloat() * 0.003f) * 20.0f, 0.0f) + GlStateManager.matrixMode(5888) + layerArmorBase.getArmorModel(armorSlot)!!.render( + entitylivingbaseIn, + p_177182_2_, + p_177182_3_, + p_177182_5_, + p_177182_6_, + p_177182_7_, + scale + ) + } + GlStateManager.matrixMode(5890) + GlStateManager.loadIdentity() + GlStateManager.matrixMode(5888) + GlStateManager.enableLighting() + GlStateManager.depthMask(true) + GlStateManager.depthFunc(515) + GlStateManager.disableBlend() + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCreeperChargeHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCreeperChargeHook.kt new file mode 100644 index 00000000..6261714e --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCreeperChargeHook.kt @@ -0,0 +1,39 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import skytils.skytilsmod.utils.SBInfo.mode +import org.spongepowered.asm.mixin.injection.At +import skytils.skytilsmod.Skytils +import org.spongepowered.asm.mixin.injection.ModifyArg +import net.minecraft.util.ResourceLocation +import net.minecraft.entity.monster.EntityCreeper +import net.minecraft.client.renderer.entity.layers.LayerRenderer +import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge +import org.spongepowered.asm.mixin.Mixin +import skytils.skytilsmod.utils.* + +val VISIBLE_CREEPER_ARMOR = ResourceLocation("skytils", "creeper_armor.png") + +fun modifyChargedCreeperLayer(res: ResourceLocation): ResourceLocation { + var res = res + if (Utils.inSkyblock && Skytils.config.moreVisibleGhosts && mode == "mining_3") { + res = VISIBLE_CREEPER_ARMOR + } + return res +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCustomHeadHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCustomHeadHook.kt new file mode 100644 index 00000000..c035e679 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/LayerCustomHeadHook.kt @@ -0,0 +1,131 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import org.spongepowered.asm.mixin.injection.Inject +import org.spongepowered.asm.mixin.injection.At +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.entity.EntityPlayerSP +import net.minecraft.entity.EntityLivingBase +import net.minecraft.client.renderer.entity.layers.LayerRenderer +import net.minecraft.client.renderer.entity.layers.LayerCustomHead +import net.minecraft.client.renderer.OpenGlHelper +import org.lwjgl.opengl.GL11 +import org.spongepowered.asm.mixin.Mixin +import skytils.skytilsmod.utils.* + +fun renderCustomHeadLayer( + entity: EntityLivingBase, + p_177141_2_: Float, + p_177141_3_: Float, + partialTicks: Float, + p_177141_5_: Float, + p_177141_6_: Float, + p_177141_7_: Float, + scale: Float, + ci: CallbackInfo +) { + if (!Utils.inSkyblock) return + if (entity is EntityPlayerSP) { + if (Skytils.config.transparentHeadLayer == 0f) { + GlStateManager.popMatrix() + ci.cancel() + return + } + if (Skytils.config.transparentHeadLayer != 1f) { + if (entity.hurtTime > 0) { + // See net.minecraft.client.renderer.entity.RendererLivingEntity.unsetBrightness + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit) + GlStateManager.enableTexture2D() + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, OpenGlHelper.defaultTexUnit) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PRIMARY_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, OpenGlHelper.defaultTexUnit) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_ALPHA, OpenGlHelper.GL_PRIMARY_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_ALPHA, GL11.GL_SRC_ALPHA) + GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, GL11.GL_TEXTURE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PREVIOUS) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, GL11.GL_TEXTURE) + GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f) + GlStateManager.setActiveTexture(OpenGlHelper.GL_TEXTURE2) + GlStateManager.disableTexture2D() + GlStateManager.bindTexture(0) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, OpenGlHelper.GL_COMBINE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_RGB, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND1_RGB, GL11.GL_SRC_COLOR) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_RGB, GL11.GL_TEXTURE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE1_RGB, OpenGlHelper.GL_PREVIOUS) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_COMBINE_ALPHA, GL11.GL_MODULATE) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_OPERAND0_ALPHA, GL11.GL_SRC_ALPHA) + GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, OpenGlHelper.GL_SOURCE0_ALPHA, GL11.GL_TEXTURE) + GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit) + } + GlStateManager.enableAlpha() + GlStateManager.enableBlend() + GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0) + GlStateManager.color(1f, 1f, 1f, Skytils.config.transparentHeadLayer) + } + } +} + +fun renderCustomHeadLayerPost( + entity: EntityLivingBase, + p_177141_2_: Float, + p_177141_3_: Float, + partialTicks: Float, + p_177141_5_: Float, + p_177141_6_: Float, + p_177141_7_: Float, + scale: Float, + ci: CallbackInfo +) { + GlStateManager.disableBlend() +} + +fun renderGlintOnSkull( + entitylivingbaseIn: EntityLivingBase, + p_177141_2_: Float, + p_177141_3_: Float, + partialTicks: Float, + p_177141_5_: Float, + p_177141_6_: Float, + p_177141_7_: Float, + scale: Float, + ci: CallbackInfo +) { + val itemStack = entitylivingbaseIn.getCurrentArmor(3) + if (Utils.inSkyblock && Skytils.config.enchantGlintFix && itemStack.hasEffect()) { + Utils.lastRenderedSkullStack = itemStack + Utils.lastRenderedSkullEntity = entitylivingbaseIn + } +} diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderBatHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderBatHook.kt new file mode 100644 index 00000000..175ac7c8 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderBatHook.kt @@ -0,0 +1,35 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.passive.EntityBat +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.features.impl.handlers.MayorInfo.currentMayor +import skytils.skytilsmod.utils.Utils +import skytils.skytilsmod.utils.Utils.equalsOneOf +import skytils.skytilsmod.utils.baseMaxHealth + +fun preRenderBat(bat: EntityBat, partialTicks: Float, ci: CallbackInfo) { + if (Utils.inDungeons && Skytils.config.biggerBatModels && + if (currentMayor == "Derpy") equalsOneOf(bat.baseMaxHealth, 200, 800) else equalsOneOf(bat.baseMaxHealth, 100, 400) + ) { + GlStateManager.scale(3f, 3f, 3f) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderEntityItemHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderEntityItemHook.kt new file mode 100644 index 00000000..9212460b --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderEntityItemHook.kt @@ -0,0 +1,38 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.item.EntityItem +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.utils.Utils + +fun scaleItemDrop( + entity: EntityItem, + x: Double, + y: Double, + z: Double, + entityYaw: Float, + partialTicks: Float, + ci: CallbackInfo +) { + if (!Utils.inSkyblock) return + val scale = Skytils.config.itemDropScale + GlStateManager.scale(scale, scale, scale) +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderHook.kt new file mode 100644 index 00000000..7a309591 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderHook.kt @@ -0,0 +1,58 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.entity.Entity +import net.minecraft.util.Vec3 +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.utils.Utils + +fun removeEntityOnFire( + entity: Entity, + x: Double, + y: Double, + z: Double, + partialTicks: Float, + ci: CallbackInfo +) { + if (Skytils.config.hideEntityFire && Utils.inSkyblock) { + ci.cancel() + } +} + +fun renderLivingLabel( + entityIn: Entity, + str: String, + x: Double, + y: Double, + z: Double, + maxDistance: Int, + ci: CallbackInfo +) { + if (Skytils.config.lowerEndermanNametags && (str.contains("❤") || str.contains("Hits")) && (str.contains("Enderman") || str.contains( + "Zealot" + ) || str.contains("Voidling") || str.contains("Voidgloom")) + ) { + val player = mc.thePlayer + val vec3 = Vec3(entityIn.posX - player.posX, 0.0, entityIn.posZ - player.posZ).normalize() + GlStateManager.translate(-vec3.xCoord, -1.5, -vec3.zCoord) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderItemHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderItemHook.kt new file mode 100644 index 00000000..a5925b29 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderItemHook.kt @@ -0,0 +1,125 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.Minecraft +import net.minecraft.client.gui.FontRenderer +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.renderer.texture.TextureMap +import net.minecraft.client.resources.model.IBakedModel +import net.minecraft.init.Items +import net.minecraft.item.ItemStack +import net.minecraft.util.ChatComponentText +import net.minecraft.util.ResourceLocation +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.events.GuiRenderItemEvent +import skytils.skytilsmod.features.impl.handlers.GlintCustomizer +import skytils.skytilsmod.mixins.transformers.accessors.AccessorRenderItem +import skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID +import skytils.skytilsmod.utils.NEUCompatibility.isCustomAHActive +import skytils.skytilsmod.utils.NEUCompatibility.isStorageMenuActive +import skytils.skytilsmod.utils.NEUCompatibility.isTradeWindowActive +import skytils.skytilsmod.utils.RenderUtil.renderRarity +import skytils.skytilsmod.utils.Utils + +val RES_ITEM_GLINT = ResourceLocation("textures/misc/enchanted_item_glint.png") + +fun renderRarity(stack: ItemStack, x: Int, y: Int, ci: CallbackInfo) { + if (Utils.inSkyblock && Skytils.config.showItemRarity) { + if (mc.currentScreen != null) { + val name = mc.currentScreen.javaClass.name + if (isStorageMenuActive || isTradeWindowActive || isCustomAHActive) { + renderRarity(stack, x, y) + } + } + } +} + +fun renderItemOverlayPost( + fr: FontRenderer, + stack: ItemStack, + xPosition: Int, + yPosition: Int, + text: String, + ci: CallbackInfo +) { + try { + MinecraftForge.EVENT_BUS.post( + GuiRenderItemEvent.RenderOverlayEvent.Post( + fr, + stack, + xPosition, + yPosition, + text + ) + ) + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at GuiRenderItemEvent.RenderOverlayEvent.Post. Please report this on the Discord server.")) + e.printStackTrace() + } +} + +fun renderItemPre(stack: ItemStack, model: IBakedModel, ci: CallbackInfo) { + if (!Utils.inSkyblock) return + if (stack.item === Items.skull) { + val scale = Skytils.config.largerHeadScale.toDouble() + GlStateManager.scale(scale, scale, scale) + } +} + +fun modifyGlintRendering(stack: ItemStack, model: IBakedModel, ci: CallbackInfo) { + if (Utils.inSkyblock) { + val itemId = getSkyBlockItemID(stack) + if (GlintCustomizer.glintColors.containsKey(itemId)) { + val color = GlintCustomizer.glintColors[itemId]!!.toInt() + GlStateManager.depthMask(false) + GlStateManager.depthFunc(514) + GlStateManager.disableLighting() + GlStateManager.blendFunc(768, 1) + mc.textureManager.bindTexture(RES_ITEM_GLINT) + GlStateManager.matrixMode(5890) + GlStateManager.pushMatrix() + GlStateManager.scale(8.0f, 8.0f, 8.0f) + val f = (Minecraft.getSystemTime() % 3000L).toFloat() / 3000.0f / 8.0f + GlStateManager.translate(f, 0.0f, 0.0f) + GlStateManager.rotate(-50.0f, 0.0f, 0.0f, 1.0f) + (mc.renderItem as AccessorRenderItem).invokeRenderModel(model, color) + GlStateManager.popMatrix() + GlStateManager.pushMatrix() + GlStateManager.scale(8.0f, 8.0f, 8.0f) + val f1 = (Minecraft.getSystemTime() % 4873L).toFloat() / 4873.0f / 8.0f + GlStateManager.translate(-f1, 0.0f, 0.0f) + GlStateManager.rotate(10.0f, 0.0f, 0.0f, 1.0f) + (mc.renderItem as AccessorRenderItem).invokeRenderModel(model, color) + GlStateManager.popMatrix() + GlStateManager.matrixMode(5888) + GlStateManager.blendFunc(770, 771) + GlStateManager.enableLighting() + GlStateManager.depthFunc(515) + GlStateManager.depthMask(true) + mc.textureManager.bindTexture(TextureMap.locationBlocksTexture) + ci.cancel() + + //Since we prematurely exited, we need to reset the matrices + GlStateManager.popMatrix() + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderManagerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderManagerHook.kt new file mode 100644 index 00000000..ff78cf02 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RenderManagerHook.kt @@ -0,0 +1,51 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.culling.ICamera +import net.minecraft.entity.Entity +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.events.CheckRenderEntityEvent + +fun shouldRender( + entityIn: Entity, + camera: ICamera, + camX: Double, + camY: Double, + camZ: Double, + cir: CallbackInfoReturnable<Boolean> +) { + try { + if (MinecraftForge.EVENT_BUS.post( + CheckRenderEntityEvent( + entityIn, + camera, + camX, + camY, + camZ + ) + ) + ) cir.returnValue = false + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at CheckRenderEntityEvent. Please report this on the Discord server.")) + e.printStackTrace() + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RendererLivingEntityHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RendererLivingEntityHook.kt new file mode 100644 index 00000000..56de558e --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/RendererLivingEntityHook.kt @@ -0,0 +1,45 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import skytils.skytilsmod.features.impl.misc.SlayerFeatures.Companion.slayerEntity +import skytils.skytilsmod.features.impl.misc.SlayerFeatures.Companion.yangGlyphEntity +import skytils.skytilsmod.features.impl.misc.SlayerFeatures.Companion.yangGlyph +import skytils.skytilsmod.features.impl.misc.SlayerFeatures.Companion.slayerNameEntity +import skytils.skytilsmod.Skytils +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import net.minecraft.entity.monster.EntityEnderman +import net.minecraft.entity.Entity +import skytils.skytilsmod.utils.* + +fun setColorMultiplier( + entity: Entity, + lightBrightness: Float, + partialTickTime: Float, + cir: CallbackInfoReturnable<Int> +) { + if (Skytils.config.recolorSeraphBoss && Utils.inSkyblock && entity is EntityEnderman) { + if (slayerEntity != entity) return + entity.hurtTime = 0 + if (yangGlyphEntity != null || yangGlyph != null) { + cir.setReturnValue(Skytils.config.seraphBeaconPhaseColor.withAlpha(169)) + } else if (slayerNameEntity != null && slayerNameEntity!!.customNameTag.endsWith("Hits")) { + cir.setReturnValue(Skytils.config.seraphHitsPhaseColor.withAlpha(169)) + } else cir.setReturnValue(Skytils.config.seraphNormalPhaseColor.withAlpha(169)) + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityChestRendererHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityChestRendererHook.kt new file mode 100644 index 00000000..62c2879b --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityChestRendererHook.kt @@ -0,0 +1,52 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.tileentity.TileEntityChest +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.features.impl.dungeons.solvers.ThreeWeirdosSolver +import skytils.skytilsmod.utils.bindColor +import java.awt.Color + +fun setChestColor( + te: TileEntityChest, + x: Double, + y: Double, + z: Double, + partialTicks: Float, + destroyStage: Int, + ci: CallbackInfo +) { + if (te.pos == ThreeWeirdosSolver.riddleChest) { + Color.RED.bindColor() + GlStateManager.disableTexture2D() + } +} + +fun setChestColorPost( + te: TileEntityChest, + x: Double, + y: Double, + z: Double, + partialTicks: Float, + destroyStage: Int, + ci: CallbackInfo +) { + GlStateManager.enableTexture2D() +} diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityItemStackRendererHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityItemStackRendererHook.kt new file mode 100644 index 00000000..ae52e469 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntityItemStackRendererHook.kt @@ -0,0 +1,31 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import net.minecraft.item.ItemStack +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.utils.Utils + +fun fixGlintForSkulls(itemStack: ItemStack, ci: CallbackInfo) { + if (Utils.inSkyblock && Skytils.config.enchantGlintFix && itemStack.hasEffect()) { + Utils.lastRenderedSkullStack = itemStack + Utils.lastRenderedSkullEntity = mc.thePlayer + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntitySkullRendererHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntitySkullRendererHook.kt new file mode 100644 index 00000000..bdd89593 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/renderer/TileEntitySkullRendererHook.kt @@ -0,0 +1,94 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.renderer + +import com.mojang.authlib.GameProfile +import net.minecraft.client.model.ModelBase +import net.minecraft.client.renderer.GlStateManager +import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer +import net.minecraft.entity.EntityLivingBase +import net.minecraft.util.EnumFacing +import net.minecraft.util.ResourceLocation +import org.spongepowered.asm.mixin.* +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo +import skytils.skytilsmod.Skytils.Companion.mc +import skytils.skytilsmod.features.impl.handlers.GlintCustomizer +import skytils.skytilsmod.utils.* +import skytils.skytilsmod.utils.ItemUtil.getSkyBlockItemID +import skytils.skytilsmod.utils.RenderUtil.getPartialTicks +import skytils.skytilsmod.utils.graphics.colors.CustomColor + +val instance: TileEntitySkullRenderer = TileEntitySkullRenderer.instance +private val ENCHANTED_ITEM_GLINT_RES = ResourceLocation("textures/misc/enchanted_item_glint.png") + +fun addGlintToSkull( + x: Float, + y: Float, + z: Float, + face: EnumFacing, + rotation: Float, + type: Int, + profile: GameProfile, + p_180543_8_: Int, + ci: CallbackInfo, + model: ModelBase +) { + if (Utils.lastRenderedSkullStack != null && Utils.lastRenderedSkullEntity != null) { + val itemId = getSkyBlockItemID(Utils.lastRenderedSkullStack) + if (GlintCustomizer.glintColors.containsKey(itemId)) { + val color = GlintCustomizer.glintColors[itemId] + renderGlint(Utils.lastRenderedSkullEntity, model, rotation, color) + } else renderGlint(Utils.lastRenderedSkullEntity, model, rotation, null) + Utils.lastRenderedSkullStack = null + Utils.lastRenderedSkullEntity = null + } +} + +fun renderGlint(entity: EntityLivingBase?, model: ModelBase?, rotation: Float, color: CustomColor?) { + val partialTicks = getPartialTicks() + val f = entity!!.ticksExisted.toFloat() + partialTicks + mc.textureManager.bindTexture(ENCHANTED_ITEM_GLINT_RES) + GlStateManager.enableBlend() + GlStateManager.depthFunc(514) + GlStateManager.depthMask(false) + val f1 = 0.5f + GlStateManager.color(f1, f1, f1, 1.0f) + //GlintCustomizer.glintColors.get(itemId).applyColor(); + for (i in 0..1) { + GlStateManager.disableLighting() + GlStateManager.blendFunc(768, 1) + val f2 = 0.76f + if (color == null) GlStateManager.color(0.5f * f2, 0.25f * f2, 0.8f * f2, 1.0f) else color.applyColor() + GlStateManager.matrixMode(5890) + GlStateManager.loadIdentity() + val f3 = 0.33333334f + GlStateManager.scale(f3, f3, f3) + GlStateManager.rotate(30.0f - i.toFloat() * 60.0f, 0.0f, 0.0f, 1.0f) + GlStateManager.translate(0.0f, f * (0.001f + i.toFloat() * 0.003f) * 20.0f, 0.0f) + GlStateManager.matrixMode(5888) + model!!.render(null, 0f, 0f, 0f, rotation, 0f, f) + } + GlStateManager.matrixMode(5890) + GlStateManager.loadIdentity() + GlStateManager.matrixMode(5888) + GlStateManager.enableLighting() + GlStateManager.depthMask(true) + GlStateManager.depthFunc(515) + //GlStateManager.disableBlend(); + GlStateManager.blendFunc(770, 771) +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/util/IChatComponent$SerializerHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/util/IChatComponent$SerializerHook.kt new file mode 100644 index 00000000..d6fda541 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/util/IChatComponent$SerializerHook.kt @@ -0,0 +1,27 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.util + +import gg.essential.universal.wrappers.message.UTextComponent +import net.minecraft.util.IChatComponent + +fun fixUTextComponentSerialize(component: IChatComponent): IChatComponent { + return if (component is UTextComponent) { + component.component + } else component +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/ChunkHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/ChunkHook.kt new file mode 100644 index 00000000..b63c9708 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/ChunkHook.kt @@ -0,0 +1,41 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.world + +import net.minecraft.block.state.IBlockState +import net.minecraft.client.Minecraft +import net.minecraft.util.BlockPos +import net.minecraft.util.ChatComponentText +import net.minecraft.world.chunk.Chunk +import net.minecraftforge.common.MinecraftForge +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable +import skytils.skytilsmod.events.BlockChangeEvent + +fun onBlockChange(chunk: Any, pos: BlockPos, state: IBlockState, cir: CallbackInfoReturnable<IBlockState>) { + (chunk as Chunk).apply { + val old = chunk.getBlockState(pos) + if (old != state) { + try { + MinecraftForge.EVENT_BUS.post(BlockChangeEvent(pos, old, state)) + } catch (e: Throwable) { + Minecraft.getMinecraft().ingameGUI.chatGUI.printChatMessage(ChatComponentText("§cSkytils caught and logged an exception at BlockChangeEvent. Please report this on the Discord server.")) + e.printStackTrace() + } + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/WorldHook.kt b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/WorldHook.kt new file mode 100644 index 00000000..03a803c6 --- /dev/null +++ b/src/main/kotlin/skytils/skytilsmod/mixins/hooks/world/WorldHook.kt @@ -0,0 +1,26 @@ +/* + * Skytils - Hypixel Skyblock Quality of Life Mod + * Copyright (C) 2021 Skytils + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +package skytils.skytilsmod.mixins.hooks.world + +import net.minecraft.world.World +import skytils.skytilsmod.Skytils +import skytils.skytilsmod.utils.Utils + +fun lightningSkyColor(world: World): Int { + return if (Skytils.config.hideLightning && Utils.inSkyblock) 0 else world.lastLightningBolt +}
\ No newline at end of file diff --git a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt index e8693075..3ae04770 100644 --- a/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt +++ b/src/main/kotlin/skytils/skytilsmod/tweaker/SkytilsLoadingPluginKt.kt @@ -117,7 +117,7 @@ class SkytilsLoadingPluginKt : IFMLLoadingPlugin { } showMessage( """ - #Skytils has detected that you are using an old version of Forge. + #Skytils has detected that you are using an old version of Forge (build ${forgeVersion}). #In order to resolve this issue and launch the game, #please install Minecraft Forge build 2318 for Minecraft 1.8.9. #If you have already done this and are still getting this error, diff --git a/src/main/kotlin/skytils/skytilsmod/utils/RenderUtil.kt b/src/main/kotlin/skytils/skytilsmod/utils/RenderUtil.kt index d3d97f3e..20ae7578 100644 --- a/src/main/kotlin/skytils/skytilsmod/utils/RenderUtil.kt +++ b/src/main/kotlin/skytils/skytilsmod/utils/RenderUtil.kt @@ -30,10 +30,9 @@ import net.minecraft.inventory.Slot import net.minecraft.item.ItemStack import net.minecraft.util.* import org.lwjgl.opengl.GL11 -import org.lwjgl.opengl.GLContext import skytils.skytilsmod.Skytils import skytils.skytilsmod.Skytils.Companion.mc -import skytils.skytilsmod.mixins.accessors.AccessorMinecraft +import skytils.skytilsmod.mixins.transformers.accessors.AccessorMinecraft import java.awt.Color import kotlin.math.cos import kotlin.math.roundToInt diff --git a/src/main/kotlin/skytils/skytilsmod/utils/StringUtils.kt b/src/main/kotlin/skytils/skytilsmod/utils/StringUtils.kt index d459bb51..6eeace5c 100644 --- a/src/main/kotlin/skytils/skytilsmod/utils/StringUtils.kt +++ b/src/main/kotlin/skytils/skytilsmod/utils/StringUtils.kt @@ -20,10 +20,12 @@ package skytils.skytilsmod.utils import gg.essential.universal.wrappers.message.UTextComponent import org.apache.commons.lang3.StringUtils as ApacheStringUtils +fun CharSequence?.countMatches(subString: CharSequence): Int = ApacheStringUtils.countMatches(this, subString) + fun String?.stripControlCodes(): String = UTextComponent.stripFormatting(this ?: "") -fun String?.startsWithAny(vararg sequences: CharSequence?) = ApacheStringUtils.startsWithAny(this, *sequences) -fun String?.containsAny(vararg sequences: CharSequence?): Boolean { +fun CharSequence?.startsWithAny(vararg sequences: CharSequence?) = ApacheStringUtils.startsWithAny(this, *sequences) +fun CharSequence?.containsAny(vararg sequences: CharSequence?): Boolean { if (this == null) return false return sequences.any { it != null && this.contains(it) } } diff --git a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt index 4f647b77..a3ffa50e 100644 --- a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt +++ b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt @@ -41,7 +41,7 @@ import net.minecraftforge.common.MinecraftForge import skytils.skytilsmod.Skytils import skytils.skytilsmod.Skytils.Companion.mc import skytils.skytilsmod.events.PacketEvent.ReceiveEvent -import skytils.skytilsmod.mixins.accessors.AccessorGuiNewChat +import skytils.skytilsmod.mixins.transformers.accessors.AccessorGuiNewChat import skytils.skytilsmod.utils.graphics.colors.ColorFactory.web import skytils.skytilsmod.utils.graphics.colors.CustomColor import skytils.skytilsmod.utils.graphics.colors.RainbowColor.Companion.fromString diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json index efb5c1c5..693da5e5 100644 --- a/src/main/resources/mixins.skytils.json +++ b/src/main/resources/mixins.skytils.json @@ -1,8 +1,8 @@ { "compatibilityLevel": "JAVA_8", "minVersion": "0.7", - "plugin": "skytils.skytilsmod.tweaker.SkytilsMixinPlugin", - "package": "skytils.skytilsmod.mixins", + "plugin": "skytils.skytilsmod.mixins.SkytilsMixinPlugin", + "package": "skytils.skytilsmod.mixins.transformers", "refmap": "mixins.skytils.refmap.json", "mixins": [ "MixinMinecraft", @@ -12,6 +12,7 @@ "accessors.AccessorGuiEditSign", "accessors.AccessorGuiNewChat", "accessors.AccessorMinecraft", + "accessors.AccessorRenderItem", "accessors.AccessorSettingsGui", "audio.MixinSoundManager", "crash.MixinCrashReport", |