Skip to content

Commit

Permalink
Update companion mod to 1.20+
Browse files Browse the repository at this point in the history
  • Loading branch information
2008Choco committed Jun 26, 2023
1 parent 428e637 commit 545ccd0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 29 deletions.
7 changes: 3 additions & 4 deletions veinminer-fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Fabric Properties. (Check these on https://fabricmc.net/develop)
minecraft_version=1.19.3
loader_version=0.14.12
minecraft_version=1.20.1
loader_version=0.14.21

#Fabric api
fabric_version=0.71.0+1.19.3
fabric_version=0.84.0+1.20.1
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void onInitializeClient() {
}

// Updating the new last looked at position
if (client.player != null && client.player.level != null && !client.player.level.isEmptyBlock(position)) {
if (client.player != null && client.player.level() != null && !client.player.level().isEmptyBlock(position)) {
getServerState().setLastLookedAt(position, blockFace);
} else {
getServerState().setLastLookedAt(null, null);
Expand Down Expand Up @@ -154,7 +154,7 @@ else if (KEY_MAPPING_PREVIOUS_PATTERN.isDown()) {
serverState.sendMessage(new PluginMessageServerboundHandshake(VeinMiner.PROTOCOL.getVersion()));
});

HudRenderCallback.EVENT.register((stack, tickDelta) -> {
HudRenderCallback.EVENT.register((graphics, tickDelta) -> {
if (!hasServerState() || !getServerState().isEnabledOnServer()) {
return;
}
Expand All @@ -167,7 +167,7 @@ else if (KEY_MAPPING_PREVIOUS_PATTERN.isDown()) {
continue;
}

component.render(client, stack, tickDelta);
component.render(client, graphics, tickDelta);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;

import org.jetbrains.annotations.NotNull;

Expand All @@ -17,10 +18,10 @@ public interface HudRenderComponent {
* Render the component to the given {@link PoseStack}.
*
* @param client the client instance
* @param stack the stack to which the hud is being rendered
* @param graphics the gui graphics
* @param tickDelta tick delta time
*/
public void render(@NotNull Minecraft client, @NotNull PoseStack stack, float tickDelta);
public void render(@NotNull Minecraft client, @NotNull GuiGraphics graphics, float tickDelta);

/**
* Check whether or not this component should be rendered to the screen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;

Expand All @@ -25,9 +26,10 @@ public final class HudRenderComponentPatternWheel implements HudRenderComponent
private float remainingMs = -1L;

@Override
public void render(@NotNull Minecraft client, @NotNull PoseStack stack, float tickDelta) {
public void render(@NotNull Minecraft client, @NotNull GuiGraphics graphics, float tickDelta) {
client.getProfiler().push("veinminerPatternWheel");

PoseStack stack = graphics.pose();
stack.pushPose();
stack.translate(4, 0, 0);

Expand All @@ -54,13 +56,13 @@ else if (remainingMs < FADE_MS) { // Fade out
String selected = serverState.getSelectedPattern().toString();
String after = serverState.getNextPattern().toString();

client.font.drawShadow(stack, Component.literal(selected), 0, client.font.lineHeight, colour);
graphics.drawString(client.font, Component.literal(selected), 0, client.font.lineHeight, colour);

stack.pushPose();
stack.translate(0, 3, 0);
stack.scale(0.6F, 0.6F, 0.6F);
client.font.drawShadow(stack, Component.literal(before), 0, 0, colour);
client.font.drawShadow(stack, Component.literal(after), 0, client.font.lineHeight * 3, colour);
graphics.drawString(client.font, Component.literal(before), 0, 0, colour);
graphics.drawString(client.font, Component.literal(after), 0, client.font.lineHeight * 3, colour);
stack.popPose();

RenderSystem.disableBlend();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package wtf.choco.veinminer.hud;

import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;

import org.jetbrains.annotations.NotNull;
Expand All @@ -19,23 +16,16 @@
*/
public final class HudRenderComponentVeinMiningIcon implements HudRenderComponent {

private static final ResourceLocation TEXTURE_VEINMINER_ICON = new ResourceLocation("veinminer_companion", "textures/gui/veinminer_icon.png");
private static final ResourceLocation VEINMINER_ICON_LOCATION = new ResourceLocation("veinminer_companion", "textures/gui/veinminer_icon.png");

@Override
public void render(@NotNull Minecraft client, @NotNull PoseStack stack, float delta) {
public void render(@NotNull Minecraft client, @NotNull GuiGraphics graphics, float delta) {
client.getProfiler().push("veinMiningIcon");

Window window = client.getWindow();
int width = window.getGuiScaledWidth(), height = window.getGuiScaledHeight();

stack.pushPose();

RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShaderTexture(0, TEXTURE_VEINMINER_ICON);
GuiComponent.blit(stack, (width / 2) + 8, (height / 2) - 4, 0, 0, 8, 8, 8, 8);

stack.popPose();
graphics.blit(VEINMINER_ICON_LOCATION, (width / 2) + 8, (height / 2) - 4, 0, 0, 8, 8, 8, 8);

client.getProfiler().pop();
}
Expand Down
4 changes: 2 additions & 2 deletions veinminer-fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
"accessWidener" : "veinminer_companion.accesswidener",

"depends": {
"fabricloader": ">=0.10",
"fabricloader": ">=0.10",
"fabric": "*",
"minecraft": ">=1.19.3",
"minecraft": ">=1.20",
"java": ">=17"
}
}

0 comments on commit 545ccd0

Please sign in to comment.