Skip to content

Commit

Permalink
chore: fix 1.21.4 porting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
inglettronald committed Dec 7, 2024
1 parent 93257ff commit a4099ee
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import com.dulkirfabric.config.DulkirConfig;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.AbstractInventoryScreen;
import net.minecraft.client.gui.screen.ingame.StatusEffectsDisplay;
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;

@Mixin(AbstractInventoryScreen.class)
@Mixin(StatusEffectsDisplay.class)
public class AbstractInventoryScreenMixin {

@Inject(
method = "drawStatusEffects",
method = "drawStatusEffects(Lnet/minecraft/client/gui/DrawContext;II)V",
at = @At("HEAD"),
cancellable = true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.client.gui.tooltip.TooltipComponent;
import net.minecraft.client.gui.tooltip.TooltipPositioner;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;
import org.joml.Vector2ic;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -28,14 +29,15 @@ public class DrawContextMixin {
@Shadow @Final private MatrixStack matrices;

@WrapOperation(
method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/" +
"client/gui/tooltip/TooltipPositioner;)V",
method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;" +
"IILnet/minecraft/client/gui/tooltip/TooltipPositioner;Lnet/minecraft/util/Identifier;)V",
at = @At(
target = "Lnet/minecraft/client/gui/tooltip/TooltipPositioner;getPosition(IIIIII)Lorg/joml/Vector2ic;",
value = "INVOKE"
)
)
public Vector2ic drawTooltip(TooltipPositioner positionerInstance, int sw, int sh, int mx, int my, int tw, int th, Operation<Vector2ic> operation) {
public Vector2ic drawTooltip(TooltipPositioner positionerInstance, int sw, int sh, int mx, int my, int tw,
int th, Operation<Vector2ic> operation) {
Screen screen = MinecraftClient.getInstance().currentScreen;
if (!(screen instanceof HandledScreen)) {
return operation.call(positionerInstance, sw, sh, mx, my, tw, th);
Expand All @@ -49,15 +51,16 @@ public Vector2ic drawTooltip(TooltipPositioner positionerInstance, int sw, int s
}

@Inject(
method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/" +
"minecraft/client/gui/tooltip/TooltipPositioner;)V",
method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;II" +
"Lnet/minecraft/client/gui/tooltip/TooltipPositioner;Lnet/minecraft/util/Identifier;)V",
at = @At(
target = "Lnet/minecraft/client/util/math/MatrixStack;push()V",
value = "INVOKE",
shift = At.Shift.AFTER
)
)
public void onPush(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci) {
public void onPush(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y,
TooltipPositioner positioner, Identifier texture, CallbackInfo ci) {
if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) {
TooltipImpl.INSTANCE.applyScale(matrices);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
package com.dulkirfabric.mixin.render;

import com.dulkirfabric.events.InventoryKeyPressEvent;
import com.dulkirfabric.events.SlotRenderEvent;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.screen.slot.Slot;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;

@Mixin(HandledScreen.class)
public class HandledScreenMixin {
Expand All @@ -30,35 +25,4 @@ public void onKeyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoR
}
}

/**@Inject(method = "onMouseClick(Lnet/minecraft/screen/slot/Slot;IILnet/minecraft/screen/slot/SlotActionType;)V",
at = @At("HEAD"), cancellable = true)
public void onMouseClickedSlot(Slot slot, int slotId, int button, SlotActionType actionType, CallbackInfo ci) {
if (IsSlotProtectedEvent.shouldBlockInteraction(slot)) {
ci.cancel();
}
}*/

@Inject(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V",
shift = At.Shift.AFTER
),
locals = LocalCapture.CAPTURE_FAILHARD
)
public void onAfterDrawSlot(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci,
int i, int j, int k, Slot slot) {
SlotRenderEvent.After event = new SlotRenderEvent.After(context, slot, mouseX, mouseY, delta);
event.post();
}

@Inject(
method = "render",
at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/ingame/HandledScreen;drawSlot(Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/screen/slot/Slot;)V", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD)
public void onBeforeDrawSlot(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci, int i, int j, int k, Slot slot) {
SlotRenderEvent.Before event = new SlotRenderEvent.Before(context, slot, mouseX, mouseY, delta);
event.post();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.dulkirfabric.config.DulkirConfig;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.item.HeldItemRenderer;
Expand All @@ -12,7 +11,6 @@
import net.minecraft.util.Arm;
import net.minecraft.util.Hand;
import net.minecraft.util.math.RotationAxis;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -23,6 +21,7 @@
// SOURCE FOR A LOT OF THIS: https://github.com/cosrnic/smallviewmodel/blob/main/src/main/java/uk/cosrnic/smallviewmodel/mixin/MixinHeldItemRenderer.java
@Mixin(HeldItemRenderer.class)
public abstract class HeldItemRendererMixin {

@Shadow public abstract void resetEquipProgress(Hand hand);

@Shadow private float equipProgressMainHand;
Expand All @@ -35,10 +34,10 @@ public abstract class HeldItemRendererMixin {
"MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(Lnet/minecraft" +
"/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render" +
"/model/json/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack" +
";Lnet/minecraft/client/render/VertexConsumerProvider;I)V"
target = "Lnet/minecraft/client/render/item/HeldItemRenderer;renderItem(" +
"Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;" +
"Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;" +
"Lnet/minecraft/client/render/VertexConsumerProvider;I)V"
)
)
public void onRenderHeldItem(AbstractClientPlayerEntity player, float tickDelta, float pitch, Hand hand,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,15 @@
import com.dulkirfabric.util.Utils;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.injector.v2.WrapWithCondition;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.LayeredDrawer;
import net.minecraft.client.gui.hud.InGameHud;
import net.minecraft.client.render.RenderTickCounter;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.Text;
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.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(InGameHud.class)
Expand All @@ -35,7 +30,8 @@ public void onRenderStatusEffectOverlay(DrawContext context, RenderTickCounter t
}

@WrapWithCondition(
method = "method_55440",
method = "renderScoreboardSidebar(Lnet/minecraft/client/gui/DrawContext;" +
"Lnet/minecraft/scoreboard/ScoreboardObjective;)V",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/DrawContext;drawText(Lnet/minecraft/client/font/TextRenderer;" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.dulkirfabric.mixin.render;

import com.dulkirfabric.config.DulkirConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.InGameOverlayRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.util.math.MatrixStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -17,7 +17,7 @@ public class InGameOverlayRendererMixin {
at = @At("HEAD"),
cancellable = true
)
private static void onFireOverlay(MinecraftClient client, MatrixStack matrices, CallbackInfo ci) {
private static void onFireOverlay(MatrixStack matrices, VertexConsumerProvider vertexConsumers, CallbackInfo ci) {
if (DulkirConfig.ConfigVars.getConfigOptions().getHideFireOverlay())
ci.cancel();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public class WorldRendererMixin {

@ModifyExpressionValue(
method = "render",
method = "renderEntities",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/entity/Entity;getTeamColorValue()I"
Expand Down
29 changes: 0 additions & 29 deletions src/main/kotlin/com/dulkirfabric/events/SlotRenderEvent.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package com.dulkirfabric.features.filters

import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.AddParticleEvent
import com.dulkirfabric.events.EntityLoadEvent
import com.dulkirfabric.util.Utils
import meteordevelopment.orbit.EventHandler
import net.minecraft.entity.Entity
import net.minecraft.entity.LightningEntity
import net.minecraft.world.event.GameEvent

object Lightning {
@EventHandler
fun cull(event: EntityLoadEvent) {
if (!DulkirConfig.configOptions.hideLightning) return
if (!Utils.isInSkyblock()) return
if (event.entity is LightningEntity) {
event.entity.kill()
event.entity.remove(Entity.RemovalReason.KILLED)
event.entity.emitGameEvent(GameEvent.ENTITY_DIE)
}
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/com/dulkirfabric/features/slayer/Demonlord.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import com.dulkirfabric.util.TextUtils
import com.dulkirfabric.util.Utils.getInterpolatedPos
import com.dulkirfabric.util.render.WorldRenderUtils
import meteordevelopment.orbit.EventHandler
import net.minecraft.entity.Entity
import net.minecraft.entity.decoration.ArmorStandEntity
import net.minecraft.entity.projectile.SmallFireballEntity
import net.minecraft.util.math.Box
import net.minecraft.world.event.GameEvent
import java.awt.Color

object Demonlord {
Expand Down Expand Up @@ -75,7 +77,9 @@ object Demonlord {
fun onEntityLoad(event: EntityLoadEvent) {
if (!DulkirConfig.configOptions.cleanBlaze) return
if (!inBoss) return
if (event.entity is SmallFireballEntity)
event.entity.kill()
if (event.entity is SmallFireballEntity) {
event.entity.remove(Entity.RemovalReason.KILLED)
event.entity.emitGameEvent(GameEvent.ENTITY_DIE)
}
}
}
18 changes: 9 additions & 9 deletions src/main/kotlin/com/dulkirfabric/util/render/WorldRenderUtils.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.dulkirfabric.util.render

import com.dulkirfabric.DulkirModFabric.mc
import com.mojang.blaze3d.systems.RenderSystem
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderContext
import net.minecraft.client.MinecraftClient
import net.minecraft.client.font.TextRenderer
import net.minecraft.client.gl.ShaderProgramKeys
import net.minecraft.client.render.*
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.Style
Expand Down Expand Up @@ -63,7 +63,7 @@ object WorldRenderUtils {
val matrices = context.matrixStack() ?: return
matrices.push()
val prevShader = RenderSystem.getShader()
RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram)
RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES)
RenderSystem.disableBlend()
RenderSystem.disableCull()
// RenderSystem.defaultBlendFunc()
Expand Down Expand Up @@ -107,7 +107,7 @@ object WorldRenderUtils {
RenderSystem.setShaderColor(
1f, 1f, 1f, 1f
)
RenderSystem.setShader { prevShader }
RenderSystem.setShader(prevShader)
RenderSystem.enableCull()
matrices.pop()
}
Expand All @@ -120,7 +120,7 @@ object WorldRenderUtils {
val matrices = context.matrixStack() ?: return
matrices.push()
val prevShader = RenderSystem.getShader()
RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram)
RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES)
RenderSystem.disableBlend()
RenderSystem.disableCull()
// RenderSystem.defaultBlendFunc()
Expand Down Expand Up @@ -148,7 +148,7 @@ object WorldRenderUtils {
RenderSystem.setShaderColor(
1f, 1f, 1f, 1f
)
RenderSystem.setShader { prevShader }
RenderSystem.setShader(prevShader)
RenderSystem.enableCull()
matrices.pop()
}
Expand All @@ -161,7 +161,7 @@ object WorldRenderUtils {
val matrices = context.matrixStack() ?: return
matrices.push()
val prevShader = RenderSystem.getShader()
RenderSystem.setShader(GameRenderer::getRenderTypeLinesProgram)
RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES)
RenderSystem.disableBlend()
RenderSystem.disableCull()
// RenderSystem.defaultBlendFunc()
Expand Down Expand Up @@ -193,7 +193,7 @@ object WorldRenderUtils {
RenderSystem.setShaderColor(
1f, 1f, 1f, 1f
)
RenderSystem.setShader { prevShader }
RenderSystem.setShader(prevShader)
RenderSystem.enableCull()
matrices.pop()
}
Expand Down Expand Up @@ -357,7 +357,7 @@ object WorldRenderUtils {
} else {
RenderSystem.enableDepthTest()
}
RenderSystem.setShader(GameRenderer::getPositionColorProgram)
RenderSystem.setShader(ShaderProgramKeys.POSITION_COLOR)
RenderSystem.enableBlend()
RenderSystem.defaultBlendFunc()

Expand All @@ -366,7 +366,7 @@ object WorldRenderUtils {
val buf = tes.begin(VertexFormat.DrawMode.TRIANGLE_STRIP, VertexFormats.POSITION_COLOR)
matrices.push()
matrices.translate(x - context.camera().pos.x, y - context.camera().pos.y, z - context.camera().pos.z)
WorldRenderer.renderFilledBox(matrices, buf, 0.0, 0.0, 0.0, width, height, depth,
VertexRendering.drawFilledBox(matrices, buf, 0.0, 0.0, 0.0, width, height, depth,
color.red / 255f, color.green / 255f, color.blue / 255f, color.alpha / 255f)
BufferRenderer.drawWithGlobalProgram(buf.end())
RenderSystem.enableDepthTest()
Expand Down

0 comments on commit a4099ee

Please sign in to comment.