Skip to content

Commit

Permalink
Update to 1.20.1, fix config screen reset
Browse files Browse the repository at this point in the history
  • Loading branch information
tr7zw committed Jul 23, 2023
1 parent b19bf7e commit 8d8ca2f
Show file tree
Hide file tree
Showing 18 changed files with 197 additions and 160 deletions.
2 changes: 1 addition & 1 deletion FG-Fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@
"accessWidener" : "exordium.accesswidener",
"depends": {
"fabric": "*",
"minecraft": ">=1.19.4"
"minecraft": ">=1.20.1"
}
}
2 changes: 1 addition & 1 deletion FG-Forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ loaderVersion="[35,)"
license="tr7zw Protective License"
[[mods]]
modId="exordium"
version="1.1.2"
version="1.1.3"
displayName="Exordium"
authors="tr7zw"
description='''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

public interface SignBufferHolder {

public boolean renderBuffered(PoseStack poseStack, MultiBufferSource multiBufferSource, int light);
public boolean renderBuffered(PoseStack poseStack, MultiBufferSource multiBufferSource, boolean front, int light);

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@
import net.minecraft.client.gui.screens.Screen;

public class ExordiumConfigScreen extends CustomConfigScreen {

private Config config;

public ExordiumConfigScreen(Screen lastScreen) {
super(lastScreen, "text.exordium.title");
this.config = ExordiumModBase.instance.config;
}

@Override
public void initialize() {
Config config = ExordiumModBase.instance.config;
List<OptionInstance<?>> options = new ArrayList<>();

options.add(getOnOffOption("text.exordium.enableSignBuffering", () -> config.enableSignBuffering,
Expand Down Expand Up @@ -59,8 +57,9 @@ public void save() {

@Override
public void reset() {
config = new Config();
ExordiumModBase.instance.config = new Config();
ExordiumModBase.instance.writeConfig();
this.rebuildWidgets();
}


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package dev.tr7zw.exordium.mixin;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.util.BufferedComponent;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.DebugScreenOverlay;

@Mixin(Gui.class)
public class GuiDebugOverlayMixin {

private BufferedComponent debugBufferedComponent = new BufferedComponent(true, ExordiumModBase.instance.config.debugScreenSettings) {

@Override
public boolean needsRender() {
return true;
}

@Override
public void captureState() {
}
};

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/DebugScreenOverlay;render(Lnet/minecraft/client/gui/GuiGraphics;)V"),
})
private void renderExperienceBarWrapper(DebugScreenOverlay overlay, GuiGraphics guiGraphics, final Operation<Void> operation) {
if (!debugBufferedComponent.render()) {
operation.call(overlay, guiGraphics);
}
debugBufferedComponent.renderEnd();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.util.BufferedComponent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;

@Mixin(Gui.class)
public class GuiExperienceMixin {
Expand All @@ -36,11 +36,11 @@ public void captureState() {
};

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderExperienceBar(Lcom/mojang/blaze3d/vertex/PoseStack;I)V"),
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderExperienceBar(Lnet/minecraft/client/gui/GuiGraphics;I)V"),
})
private void renderExperienceBarWrapper(Gui gui, PoseStack poseStack, int i, final Operation<Void> operation) {
private void renderExperienceBarWrapper(Gui gui, GuiGraphics guiGraphics, int i, final Operation<Void> operation) {
if (!experienceBuffer.render()) {
operation.call(gui, poseStack, i);
operation.call(gui, guiGraphics, i);
}
experienceBuffer.renderEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.util.BufferedComponent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.LivingEntity;
Expand Down Expand Up @@ -90,28 +90,28 @@ public void captureState() {
};

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderPlayerHealth(Lcom/mojang/blaze3d/vertex/PoseStack;)V"),
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderPlayerHealth(Lnet/minecraft/client/gui/GuiGraphics;)V"),
})
private void renderPlayerHealthWrapper(Gui gui, PoseStack poseStack, final Operation<Void> operation) {
private void renderPlayerHealthWrapper(Gui gui, GuiGraphics guiGraphics, final Operation<Void> operation) {
if (!healthBuffer.render()) {
operation.call(gui, poseStack);
operation.call(gui, guiGraphics);
renderingMountHealth = true;
renderVehicleHealth(poseStack);
renderVehicleHealth(guiGraphics);
renderingMountHealth = false;
}
healthBuffer.renderEnd();
}

@Inject(method = "renderVehicleHealth", at = @At("HEAD"), cancellable = true)
private void renderVehicleHealthHead(PoseStack poseStack, CallbackInfo ci) {
private void renderVehicleHealthHead(GuiGraphics guiGraphics, CallbackInfo ci) {
if(!renderingMountHealth && ExordiumModBase.instance.config.healthSettings.enabled && !minecraft.player.isCreative()) {
// prevent rendering multiple times, just render into the texture
ci.cancel();
}
}

@Shadow
public abstract void renderVehicleHealth(PoseStack poseStack);
public abstract void renderVehicleHealth(GuiGraphics guiGraphics);

@Shadow
protected abstract LivingEntity getPlayerVehicleWithHealth();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.util.BufferedComponent;
import net.minecraft.client.AttackIndicatorStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -57,7 +57,7 @@ public void captureState() {

private void store(ItemStack item, int id, Player player) {
if (item != null && !item.isEmpty()) {
hotbarModels[id] = minecraft.getItemRenderer().getModel(item, player.level, player, 0);
hotbarModels[id] = minecraft.getItemRenderer().getModel(item, player.level(), player, 0);
itemPopAnimation[id] = item.getPopTime();
itemAmount[id] = item.getCount();
itemDurability[id] = item.getDamageValue();
Expand Down Expand Up @@ -86,7 +86,7 @@ private boolean hasChanged(ItemStack item, int id, Player player) {
if(itemDurability[id] != item.getDamageValue()) {
return true;
}
if(minecraft.getItemRenderer().getModel(item, player.level, player, 0) != hotbarModels[id]) {
if(minecraft.getItemRenderer().getModel(item, player.level(), player, 0) != hotbarModels[id]) {
return true;
}
} else if(hotbarModels[id] != null) {
Expand Down Expand Up @@ -125,12 +125,12 @@ public boolean hasChanged() {
}

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderHotbar(FLcom/mojang/blaze3d/vertex/PoseStack;)V"),
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;renderHotbar(FLnet/minecraft/client/gui/GuiGraphics;)V"),
})
private void renderExperienceBarWrapper(Gui gui, float f, PoseStack poseStack, final Operation<Void> operation) {
private void renderHotbarWrapper(Gui gui, float f, GuiGraphics guiGraphics, final Operation<Void> operation) {
outdated = hasChanged();
if (!bufferedComponent.render()) {
operation.call(gui, f, poseStack);
operation.call(gui, f, guiGraphics);
}
bufferedComponent.renderEnd();
}
Expand Down
8 changes: 4 additions & 4 deletions Shared/src/main/java/dev/tr7zw/exordium/mixin/GuiMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.exordium.access.ChatAccess;
import dev.tr7zw.exordium.util.BufferedComponent;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ChatComponent;

@Mixin(Gui.class)
Expand All @@ -20,14 +20,14 @@ public class GuiMixin {
private ChatComponent chat;

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;render(Lcom/mojang/blaze3d/vertex/PoseStack;III)V"),
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/components/ChatComponent;render(Lnet/minecraft/client/gui/GuiGraphics;III)V"),
})
private void renderChatWrapper(ChatComponent instance, PoseStack poseStack, int tickCount, int j, int k, final Operation<Void> operation) {
private void renderChatWrapper(ChatComponent instance, GuiGraphics guiGraphics, int tickCount, int j, int k, final Operation<Void> operation) {
ChatAccess chatAccess = (ChatAccess) chat;
chatAccess.updateState(tickCount);
BufferedComponent bufferedComponent = chatAccess.getBufferedComponent();
if(!bufferedComponent.render()) {
operation.call(instance, poseStack, tickCount, j, k);
operation.call(instance, guiGraphics, tickCount, j, k);
}
bufferedComponent.renderEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.mojang.blaze3d.vertex.PoseStack;

import dev.tr7zw.exordium.ExordiumModBase;
import dev.tr7zw.exordium.util.BufferedComponent;
import dev.tr7zw.exordium.util.ScoreboardHelper;
import dev.tr7zw.exordium.util.ScoreboardHelper.ScoreboardState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.world.scores.Objective;

@Mixin(Gui.class)
Expand All @@ -40,11 +40,11 @@ public void captureState() {
};

@WrapOperation(method = "render", at = {
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;displayScoreboardSidebar(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/world/scores/Objective;)V"),
@At(value = "INVOKE", target = "Lnet/minecraft/client/gui/Gui;displayScoreboardSidebar(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/world/scores/Objective;)V"),
})
private void displayScoreboardSidebarWrapper(Gui gui, PoseStack poseStack, Objective objective, final Operation<Void> operation) {
private void displayScoreboardSidebarWrapper(Gui gui, GuiGraphics guiGraphics, Objective objective, final Operation<Void> operation) {
if (!scoreboardBuffer.render()) {
operation.call(gui, poseStack, objective);
operation.call(gui, guiGraphics, objective);
}
scoreboardBuffer.renderEnd();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,37 @@
import net.minecraft.network.chat.Component;
import net.minecraft.world.level.block.entity.HangingSignBlockEntity;
import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.entity.SignText;

@Mixin(SignBlockEntity.class)
public class SignBlockEntityMixin implements SignBufferHolder {

private SignBufferRenderer cachedBufferRenderer = null;
private Component[] lines = new Component[4];
private SignText front;
private SignText back;
private int currentLight = -1;

// TODO: hook the update methods instead of hot checking stuff.
@Override
public boolean renderBuffered(PoseStack poseStack, MultiBufferSource multiBufferSource, int light) {
public boolean renderBuffered(PoseStack poseStack, MultiBufferSource multiBufferSource, boolean renderFront, int light) {
SignBlockEntity sign = (SignBlockEntity) (Object) this;
if (isSignEmpty(sign)) {
return true; // empty sign, nothing to do (yet)
if (isSignEmpty(sign.getFrontText()) || isSignEmpty(sign.getBackText())) {
return true; // empty sign, nothing to do
}
if (cachedBufferRenderer == null || (currentLight != light && !sign.hasGlowingText())
|| lines[0] != sign.getMessage(0, false) || lines[1] != sign.getMessage(1, false)
|| lines[2] != sign.getMessage(2, false) || lines[3] != sign.getMessage(3, false)) {
if (cachedBufferRenderer == null || currentLight != light || (renderFront && (sign.getFrontText() != front))
|| (!renderFront && (sign.getBackText() != back))) {
if (cachedBufferRenderer == null) {
cachedBufferRenderer = new SignBufferRenderer(sign, light);
}
cachedBufferRenderer.refreshImage(sign, light);
lines[0] = sign.getMessage(0, false);
lines[1] = sign.getMessage(1, false);
lines[2] = sign.getMessage(2, false);
lines[3] = sign.getMessage(3, false);
cachedBufferRenderer.refreshImage(sign, light, renderFront);
currentLight = light;
}
cachedBufferRenderer.render(poseStack, light, ((Object)this) instanceof HangingSignBlockEntity);
cachedBufferRenderer.render(poseStack, light, ((Object) this) instanceof HangingSignBlockEntity, renderFront);
return true;
}

private boolean isSignEmpty(SignBlockEntity sign) {
private boolean isSignEmpty(SignText text) {
for (int i = 0; i < 4; i++) {
Component line = sign.getMessage(i, false);
Component line = text.getMessage(i, false);
if (!line.getString().isBlank())
return false;
}
Expand Down
Loading

0 comments on commit 8d8ca2f

Please sign in to comment.