aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/MixinLayerCustomHead.java10
-rw-r--r--src/main/java/skytils/skytilsmod/mixins/MixinTileEntitySkullRenderer.java107
-rw-r--r--src/main/kotlin/skytils/skytilsmod/features/impl/trackers/MythologicalTracker.kt2
-rw-r--r--src/main/kotlin/skytils/skytilsmod/utils/Utils.kt8
-rw-r--r--src/main/resources/mixins.skytils.json3
5 files changed, 128 insertions, 2 deletions
diff --git a/src/main/java/skytils/skytilsmod/mixins/MixinLayerCustomHead.java b/src/main/java/skytils/skytilsmod/mixins/MixinLayerCustomHead.java
index 1a634923..0502a822 100644
--- a/src/main/java/skytils/skytilsmod/mixins/MixinLayerCustomHead.java
+++ b/src/main/java/skytils/skytilsmod/mixins/MixinLayerCustomHead.java
@@ -24,6 +24,7 @@ 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;
@@ -99,4 +100,13 @@ public abstract class MixinLayerCustomHead implements LayerRenderer<EntityLiving
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/MixinTileEntitySkullRenderer.java b/src/main/java/skytils/skytilsmod/mixins/MixinTileEntitySkullRenderer.java
new file mode 100644
index 00000000..72ebd962
--- /dev/null
+++ b/src/main/java/skytils/skytilsmod/mixins/MixinTileEntitySkullRenderer.java
@@ -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;
+
+import com.mojang.authlib.GameProfile;
+import net.minecraft.client.Minecraft;
+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.Utils;
+import skytils.skytilsmod.utils.graphics.colors.CustomColor;
+
+import static skytils.skytilsmod.Skytils.mc;
+
+@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 = ((AccessorMinecraft)mc).getTimer().renderPartialTicks;
+ float f = (float)entity.ticksExisted + partialTicks;
+ mc.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();
+ }
+
+}
diff --git a/src/main/kotlin/skytils/skytilsmod/features/impl/trackers/MythologicalTracker.kt b/src/main/kotlin/skytils/skytilsmod/features/impl/trackers/MythologicalTracker.kt
index 59a663d2..b003f02e 100644
--- a/src/main/kotlin/skytils/skytilsmod/features/impl/trackers/MythologicalTracker.kt
+++ b/src/main/kotlin/skytils/skytilsmod/features/impl/trackers/MythologicalTracker.kt
@@ -185,7 +185,7 @@ class MythologicalTracker : PersistentSave(File(File(Skytils.modDir, "trackers")
}
is S2FPacketSetSlot -> {
val item = event.packet.func_149174_e() ?: return
- if (event.packet.func_149175_c() != 0 || mc.thePlayer.ticksExisted <= 1) return
+ if (event.packet.func_149175_c() != 0 || mc.thePlayer == null || mc.thePlayer.ticksExisted <= 1) return
val drop = BurrowDrop.getFromId(AuctionData.getIdentifier(item)) ?: return
if (drop.isChat || drop.mobDrop) return
val extraAttr = ItemUtil.getExtraAttributes(item) ?: return
diff --git a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
index 8bb170e5..3fd0d997 100644
--- a/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
+++ b/src/main/kotlin/skytils/skytilsmod/utils/Utils.kt
@@ -19,8 +19,10 @@ package skytils.skytilsmod.utils
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiContainer
+import net.minecraft.entity.EntityLivingBase
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.inventory.Slot
+import net.minecraft.item.ItemStack
import net.minecraft.network.play.server.S02PacketChat
import net.minecraft.util.BlockPos
import net.minecraftforge.client.event.ClientChatReceivedEvent
@@ -49,6 +51,12 @@ object Utils {
@JvmField
var shouldBypassVolume = false
+ @JvmField
+ var lastRenderedSkullStack: ItemStack? = null
+
+ @JvmField
+ var lastRenderedSkullEntity: EntityLivingBase? = null
+
@JvmStatic
var random = Random()
diff --git a/src/main/resources/mixins.skytils.json b/src/main/resources/mixins.skytils.json
index 2a86d31d..b020c4e1 100644
--- a/src/main/resources/mixins.skytils.json
+++ b/src/main/resources/mixins.skytils.json
@@ -22,8 +22,8 @@
"MixinEntityRenderer",
"MixinGuiContainer",
"MixinGuiIngame",
- "MixinInventoryEffectRenderer",
"MixinGuiScreen",
+ "MixinInventoryEffectRenderer",
"MixinItemArmor",
"MixinItemStack",
"MixinLayerArmorBase",
@@ -43,6 +43,7 @@
"MixinSoundManager",
"MixinSplashProgress",
"MixinTileEntityChestRenderer",
+ "MixinTileEntitySkullRenderer",
"MixinUtil",
"MixinWorld"
],