Skip to content

Commit

Permalink
Ugh, fuck this
Browse files Browse the repository at this point in the history
  • Loading branch information
enjarai committed Nov 6, 2024
1 parent 093d303 commit 02f9427
Show file tree
Hide file tree
Showing 28 changed files with 248 additions and 859 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.render.VertexFormat;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.util.Identifier;
import net.minecraft.util.TriState;
import net.minecraft.util.Util;

import java.util.function.Function;
Expand All @@ -15,7 +16,7 @@ public class ModRenderLayers {
public static final Function<Identifier, RenderLayer> ARMOR_TRANSLUCENT_NO_CULL = Util.memoize(texture -> {
var params = RenderLayer.MultiPhaseParameters.builder()
.program(ARMOR_CUTOUT_NO_CULL_PROGRAM)
.texture(new RenderPhase.Texture(texture, false, false))
.texture(new RenderPhase.Texture(texture, TriState.DEFAULT, false))
.transparency(TRANSLUCENT_TRANSPARENCY)
.cull(DISABLE_CULLING)
.lightmap(ENABLE_LIGHTMAP)
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public abstract class GenderArmorLayerMixin {
if (entity instanceof PlayerEntity player) {
var transparency = ModConfig.INSTANCE.getApplicablePieceTransparency(player.getUuid(), HideableEquipment.CHEST);
if (transparency < 1) {
return ItemRenderer.getDirectItemGlintConsumer(vertexConsumerProvider, renderLayer, solid, hasGlint);
return ItemRenderer.getItemGlintConsumer(vertexConsumerProvider, renderLayer, solid, hasGlint);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import nl.enjarai.showmeyourskin.ShowMeYourSkin;
Expand Down Expand Up @@ -42,7 +43,7 @@ protected void renderBackgroundTextures(DrawContext context) {
int leftSide = getWindowLeft() + 3;
int topSide = getSelectorTop();

context.drawTexture(OverrideableConfigScreen.SELECTOR_TEXTURE, leftSide, topSide, 1, 1, 236, 127);
context.drawTexture(RenderLayer::getGuiTextured, OverrideableConfigScreen.SELECTOR_TEXTURE, leftSide, topSide, 1, 1, 236, 127, 256, 256);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.client.render.DiffuseLighting;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.sound.PositionedSoundInstance;
Expand Down Expand Up @@ -262,7 +263,7 @@ public void renderBackground(DrawContext context, Identifier backgroundTexture,

matrices.push();
matrices.translate(0, 0, zIndex);
context.drawTexture(backgroundTexture, leftSide, topSide, 1, 1, 236, 254);
context.drawTexture(RenderLayer::getGuiTextured, backgroundTexture, leftSide, topSide, 1, 1, 236, 254, 256, 256);
matrices.pop();

RenderSystem.disableBlend();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.sound.SoundEvents;
Expand Down Expand Up @@ -78,9 +79,9 @@ public void directRender(DrawContext context, int index, int x, int y, int mouse
RenderSystem.enableBlend();

if (selected) {
context.drawTexture(SELECTION_TEXTURE, x - 1, y - 1, 0, 0, 32, 32, 128, 128);
context.drawTexture(RenderLayer::getGuiTextured, SELECTION_TEXTURE, x - 1, y - 1, 0, 0, 32, 32, 128, 128);
} else if (hovered && children().stream().noneMatch(element -> element.isMouseOver(mouseX, mouseY))) {
context.drawTexture(SELECTION_TEXTURE, x - 1, y - 1, 32, 0, 32, 32, 128, 128);
context.drawTexture(RenderLayer::getGuiTextured, SELECTION_TEXTURE, x - 1, y - 1, 32, 0, 32, 32, 128, 128);
}

renderIcon(context, index, x, y, mouseX, mouseY, hovered, tickDelta);
Expand All @@ -89,7 +90,7 @@ public void directRender(DrawContext context, int index, int x, int y, int mouse
}

protected void renderIcon(DrawContext context, int index, int x, int y, int mouseX, int mouseY, boolean hovered, float tickDelta) {
context.drawTexture(GLOBAL_ICON, x + 3, y + 3, 24, 24, 0, 0, 24, 24, 24, 24);
context.drawTexture(RenderLayer::getGuiTextured, GLOBAL_ICON, x + 3, y + 3, 24, 24, 0, 0, 24, 24, 24, 24);
}

public void playDownSound(SoundManager soundManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.gui.screen.ButtonTextures;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.sound.PositionedSoundInstance;
import net.minecraft.client.sound.SoundManager;
import net.minecraft.client.util.SkinTextures;
Expand Down Expand Up @@ -75,9 +76,9 @@ public void directRender(DrawContext context, int index, int x, int y, int mouse

@Override
protected void renderIcon(DrawContext context, int index, int x, int y, int mouseX, int mouseY, boolean hovered, float tickDelta) {
context.drawTexture(skinTextures.get().texture(), x + 3, y + 3, 24, 24, 8.0F, 8.0F, 8, 8, 64, 64);
context.drawTexture(RenderLayer::getGuiTextured, skinTextures.get().texture(), x + 3, y + 3, 8.0F, 8.0F, 24, 24, 8, 8, 64, 64);
RenderSystem.enableBlend();
context.drawTexture(skinTextures.get().texture(), x + 3, y + 3, 24, 24, 40.0F, 8.0F, 8, 8, 64, 64);
context.drawTexture(RenderLayer::getGuiTextured, skinTextures.get().texture(), x + 3, y + 3, 40.0F, 8.0F, 24, 24, 8, 8, 64, 64);
RenderSystem.disableBlend();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.tooltip.Tooltip;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.screen.ScreenTexts;
import net.minecraft.text.Text;
import nl.enjarai.showmeyourskin.ShowMeYourSkin;
Expand Down Expand Up @@ -46,18 +47,15 @@ public boolean isEnabled() {

@Override
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
context.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha);
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();

renderButtonBackground(context, mouseX, mouseY, delta);
context.drawGuiTexture(textures.get(isEnabled(), isSelected()), this.getX(), this.getY(), this.getWidth(), this.getHeight());

context.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
context.drawGuiTexture(RenderLayer::getGuiTextured, textures.get(isEnabled(), isSelected()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
}

protected void renderButtonBackground(DrawContext context, int mouseX, int mouseY, float delta) {
context.drawGuiTexture(BACKGROUND_TEXTURES.get(isEnabled(), isSelected()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
context.drawGuiTexture(RenderLayer::getGuiTextured, BACKGROUND_TEXTURES.get(isEnabled(), isSelected()), this.getX(), this.getY(), this.getWidth(), this.getHeight());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.advancement.AdvancementTabType;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.util.Identifier;
import nl.enjarai.showmeyourskin.ShowMeYourSkin;

Expand All @@ -26,7 +27,7 @@ public void render(DrawContext context, int mouseX, int mouseY, boolean selected
int v = selected ? 64 + 28 : 64;
AdvancementTabType.LEFT.drawBackground(context, x + 28, y - 29, selected, 1); // index 1 always renders the "middle" texture
RenderSystem.enableBlend();
context.drawTexture(ICON_TEXTURE, x + (selected ? 6 : 10), y + 5, iconX, iconY, 16, 16);
context.drawTexture(RenderLayer::getGuiTextured, ICON_TEXTURE, x + (selected ? 6 : 10), y + 5, iconX, iconY, 16, 16, 256, 256);
RenderSystem.disableBlend();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package nl.enjarai.showmeyourskin.mixin;

import com.llamalad7.mixinextras.sugar.Share;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.render.entity.state.EntityRenderState;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import nl.enjarai.showmeyourskin.ShowMeYourSkin;
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(EntityRenderDispatcher.class)
public class EntityRenderDispatcherMixin {
@Inject(
method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/EntityRenderer;)V",
at = @At("HEAD")
)
private <E extends Entity, S extends EntityRenderState> void captureEntityContext(E entity, double x, double y, double z,
float tickDelta, MatrixStack matrices,
VertexConsumerProvider vertexConsumers,
int light, EntityRenderer<? super E, S> renderer,
CallbackInfo ci,
@Share(namespace = ShowMeYourSkin.MODID, value = "renderedEntity") LocalRef<Entity> ctx) {
ctx.set(entity);
}

@Inject(
method = "render(Lnet/minecraft/entity/Entity;DDDFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/EntityRenderer;)V",
at = @At("RETURN")
)
private <E extends Entity, S extends EntityRenderState> void clearEntityContext(E entity, double x, double y, double z,
float tickDelta, MatrixStack matrices,
VertexConsumerProvider vertexConsumers,
int light, EntityRenderer<? super E, S> renderer,
CallbackInfo ci,
@Share(namespace = ShowMeYourSkin.MODID, value = "renderedEntity") LocalRef<Entity> ctx) {
ctx.set(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package nl.enjarai.showmeyourskin.mixin;

import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
import nl.enjarai.showmeyourskin.util.CombatLogger;
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;

@Mixin(ClientPlayerEntity.class)
public abstract class ClientPlayerEntityMixin {
@Mixin(LivingEntity.class)
public abstract class LivingEntityMixin {
@Inject(
method = "damage(Lnet/minecraft/entity/damage/DamageSource;F)Z",
method = "onDamaged",
at = @At(value = "HEAD")
)
private void showmeyourskin$triggerCombat(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
CombatLogger.INSTANCE.triggerCombat(((ClientPlayerEntity) (Object) this).getUuid());
private void showmeyourskin$triggerCombat(DamageSource damageSource, CallbackInfo ci) {
if ((Object) this instanceof ClientPlayerEntity player) {
CombatLogger.INSTANCE.triggerCombat(player.getUuid());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
@Mixin(LivingEntityRenderer.class)
public abstract class LivingEntityRendererMixin<T extends LivingEntity> {
@Inject(
method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z",
method = "hasLabel(Lnet/minecraft/entity/LivingEntity;D)Z",
at = @At("HEAD"),
cancellable = true
)
private void showmeyourskin$removeLabel(T livingEntity, CallbackInfoReturnable<Boolean> cir) {
private void showmeyourskin$removeLabel(T livingEntity, double d, CallbackInfoReturnable<Boolean> cir) {
if (
livingEntity instanceof DummyClientPlayerEntity ||
!ModConfig.INSTANCE.getApplicable(livingEntity.getUuid()).showNameTag
Expand Down

This file was deleted.

Loading

0 comments on commit 02f9427

Please sign in to comment.