Skip to content

Commit

Permalink
backport to 1.18.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Jan 6, 2025
1 parent f68f8a8 commit dbadda9
Show file tree
Hide file tree
Showing 114 changed files with 1,030 additions and 771 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ allprojects {
maven { url = "https://maven.cafeteria.dev/releases/" }
maven { url = "https://maven.gegy.dev" }
maven { url = "https://modmaven.dev" }
maven { url = "https://maven.minecraftforge.net/"}
maven { url = "https://maven.minecraftforge.net/" }
exclusiveContent {
forRepository {
maven {
Expand Down
6 changes: 3 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ dependencies {
modApi("dev.architectury:architectury-fabric:${rootProject.architectury_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }

// for sodium compat
modCompileOnly "maven.modrinth:sodium:mc1.19.2-0.4.4"
modCompileOnly "maven.modrinth:sodium:mc1.18.2-0.4.1"

// for iris compat
modCompileOnly "maven.modrinth:iris:1.6.11+1.19.2"
modCompileOnly "maven.modrinth:iris:1.6.11+1.18.2"

// for REI compat
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:9.2.784") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:8.4.778") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }

// for Pehkui compat
modApi("com.github.Virtuoel:Pehkui:3.7.12") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" }
Expand Down
9 changes: 0 additions & 9 deletions common/src/main/java/org/vivecraft/client/Xplat.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,6 @@ static TextureAtlasSprite[] getFluidTextures(BlockAndTintGetter level, BlockPos
return new TextureAtlasSprite[]{};
}

/**
* @param biome Biome to get the ClimateSettings from
* @return ClimateSettings of the given Biome
*/
@ExpectPlatform
static Biome.ClimateSettings getBiomeClimateSettings(Biome biome) {
throw new AssertionError();
}

/**
* @param biome Biome to get the BiomeSpecialEffects from
* @return BiomeSpecialEffects of the given Biome
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.vivecraft.client.extensions;

import net.minecraft.client.model.geom.ModelPart;

public interface ModelPartExtension {
/**
* set ModelPart scale, since older Minecraft versions lack that feature
*
* @param x x scale
* @param y y scale
* @param z z scale
*/
void vivecraft$setScale(float x, float y, float z);

/**
* copies the ModelPart scale of parameters {@code this} to {@code other}
*/
void vivecraft$copyScaleTo(ModelPart other);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.client.gui.framework;

import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.settings.VRSettings;

Expand All @@ -24,7 +24,7 @@ public GuiVROptionButton(
int id, int x, int y, int width, int height, @Nullable VRSettings.VrOptions option, String text,
OnPress onPress)
{
super(x, y, width, height, Component.translatable(text), onPress);
super(x, y, width, height, new TranslatableComponent(text), onPress);
this.id = id;
this.enumOptions = option;
ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.client.gui.framework;

import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.settings.VRSettings;

Expand All @@ -17,7 +17,8 @@ public GuiVROptionSlider(
int id, int x, int y, int width, int height, VRSettings.VrOptions option, boolean valueOnly)
{
super(x, y, width, height,
Component.literal(ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(option, valueOnly)),
new TextComponent(
ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(option, valueOnly)),
option.normalizeValue(ClientDataHolderVR.getInstance().vrSettings.getOptionFloatValue(option)));

this.id = id;
Expand All @@ -38,7 +39,7 @@ public GuiVROptionSlider(int id, int x, int y, VRSettings.VrOptions option) {

@Override
protected void updateMessage() {
this.setMessage(Component.literal(
this.setMessage(new TextComponent(
ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(this.enumOptions, this.valueOnly)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.phys.Vec2;
import org.lwjgl.glfw.GLFW;
import org.vivecraft.client_vr.ClientDataHolderVR;
Expand All @@ -31,15 +32,15 @@ public abstract class GuiVROptionsBase extends Screen {
private Button btnDefaults;

public GuiVROptionsBase(Screen lastScreen) {
super(Component.literal(""));
super(new TextComponent(""));
this.lastScreen = lastScreen;
this.vrSettings = ClientDataHolderVR.getInstance().vrSettings;
}

protected void addDefaultButtons() {
this.addRenderableWidget(
this.btnDone = new Button(this.width / 2 + 5, this.height - 30, 150, 20,
Component.translatable("gui.back"), (p) -> {
new TranslatableComponent("gui.back"), (p) -> {
if (!this.onDoneClicked()) {
this.dataHolder.vrSettings.saveOptions();
this.minecraft.setScreen(this.lastScreen);
Expand All @@ -48,7 +49,7 @@ protected void addDefaultButtons() {

this.addRenderableWidget(
this.btnDefaults = new Button(this.width / 2 - 155, this.height - 30, 150, 20,
Component.translatable("vivecraft.gui.loaddefaults"), (p) -> {
new TranslatableComponent("vivecraft.gui.loaddefaults"), (p) -> {
this.loadDefaults();
this.dataHolder.vrSettings.saveOptions();
this.reinit = true;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void onClick(double mouseX, double mouseY) {
!layout.getCustomHandler().apply((GuiVROptionButton) p, new Vec2(0.0F, 0.0F)))
{
this.vrSettings.setOptionValue(((GuiVROptionButton) p).getOption());
p.setMessage(Component.literal(layout.getButtonText()));
p.setMessage(new TextComponent(layout.getButtonText()));
}
}));
} else if (layout.getScreen() != null) {
Expand Down Expand Up @@ -217,7 +218,7 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic

super.render(poseStack, mouseX, mouseY, partialTick);

drawCenteredString(poseStack, this.font, Component.translatable(this.vrTitle), this.width / 2, 15, 0xFFFFFF);
drawCenteredString(poseStack, this.font, new TranslatableComponent(this.vrTitle), this.width / 2, 15, 0xFFFFFF);

if (this.btnDefaults != null) {
this.btnDefaults.visible = this.drawDefaultButtons;
Expand Down Expand Up @@ -347,10 +348,10 @@ private void renderTooltip(PoseStack poseStack, int mouseX, int mouseY) {
if (guiHover.getY() + guiHover.getHeight() + formattedText.size() * (this.font.lineHeight + 1) +
14 < this.height)
{
renderTooltip(poseStack, this.font.split(Component.literal(tooltip), 308),
renderTooltip(poseStack, this.font.split(new TextComponent(tooltip), 308),
this.width / 2 - 166, guiHover.getY() + guiHover.getHeight() + 14);
} else {
renderTooltip(poseStack, this.font.split(Component.literal(tooltip), 308),
renderTooltip(poseStack, this.font.split(new TextComponent(tooltip), 308),
this.width / 2 - 166,
guiHover.getY() - formattedText.size() * (this.font.lineHeight + 1) + 9);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import org.joml.Matrix4f;
import org.joml.Vector2f;
import org.joml.Vector3f;
Expand All @@ -25,7 +25,7 @@ public abstract class TwoHandedScreen extends Screen {
protected boolean reinit;

protected TwoHandedScreen() {
super(Component.literal(""));
super(new TextComponent(""));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;

public class BlockedServerScreen extends Screen {

Expand All @@ -15,7 +15,7 @@ public class BlockedServerScreen extends Screen {
private MultiLineLabel message;

public BlockedServerScreen(Screen lastScreen, String server, Runnable onContinue) {
super(Component.translatable("vivecraft.messages.blocklist.title"));
super(new TranslatableComponent("vivecraft.messages.blocklist.title"));
this.lastScreen = lastScreen;
this.server = server;
this.onContinue = onContinue;
Expand All @@ -24,13 +24,13 @@ public BlockedServerScreen(Screen lastScreen, String server, Runnable onContinue
protected void init() {

this.addRenderableWidget(new Button(this.width / 2 + 5, this.height - 32, 150, 20,
Component.translatable("gui.back"), (p) ->
new TranslatableComponent("gui.back"), (p) ->
Minecraft.getInstance().setScreen(this.lastScreen)));
this.addRenderableWidget(
new Button(this.width / 2 - 155, this.height - 32, 150, 20,
Component.translatable("vivecraft.gui.continueWithout"), p -> this.onContinue.run()));
new TranslatableComponent("vivecraft.gui.continueWithout"), p -> this.onContinue.run()));
this.message = MultiLineLabel.create(this.font,
Component.translatable("vivecraft.messages.blocklist", this.server), 360);
new TranslatableComponent("vivecraft.messages.blocklist", this.server), 360);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.TranslatableComponent;
import org.jetbrains.annotations.NotNull;
import org.vivecraft.client.gui.widgets.TextScrollWidget;

Expand All @@ -29,11 +30,11 @@ protected void init() {

this.addRenderableWidget(
new Button(this.width / 2 + 5, this.height - 32, 150, 20,
Component.translatable("gui.back"),
new TranslatableComponent("gui.back"),
(p) -> Minecraft.getInstance().setScreen(this.lastScreen)));
this.addRenderableWidget(
new Button(this.width / 2 - 155, this.height - 32, 150, 20,
Component.translatable("chat.copy.click"),
new TranslatableComponent("chat.copy.click"),
(p) -> Minecraft.getInstance().keyboardHandler.setClipboard(
this.title.getString() + "\n" + this.error.getString())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
import org.joml.Quaternionf;
Expand Down Expand Up @@ -51,7 +51,7 @@ public class FBTCalibrationScreen extends Screen {
private Button cancelButton;

public FBTCalibrationScreen(Screen parent) {
super(Component.translatable("vivecraft.options.screen.fbtcalibration"));
super(new TranslatableComponent("vivecraft.options.screen.fbtcalibration"));
this.parent = parent;
// copy old settings to be able to reset them on cancel
this.wasFbtCalibrated = ClientDataHolderVR.getInstance().vrSettings.fbtCalibrated;
Expand Down Expand Up @@ -87,7 +87,7 @@ private void reset() {
ClientDataHolderVR.getInstance().vrSettings.fbtExtendedCalibrated = false;
ClientDataHolderVR.getInstance().vrSettings.unlabeledTrackersUsed = this.usingUnlabeledTrackers;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
this.cancelButton.setMessage(Component.translatable("gui.cancel"));
this.cancelButton.setMessage(new TranslatableComponent("gui.cancel"));
this.resetButton.visible = false;
}

Expand All @@ -98,23 +98,23 @@ public boolean isCalibrated() {
@Override
protected void init() {
this.calibrationText = new MultilineComponent(this.width / 2, 30, 400,
Component.translatable("vivecraft.messages.fbtcalibration"), true, this.font);
new TranslatableComponent("vivecraft.messages.fbtcalibration"), true, this.font);

this.unlabeledTrackersWarningText = new MultilineComponent(this.width / 2,
this.calibrationText.y + this.calibrationText.getHeight(), 400,
Component.translatable("vivecraft.messages.fbtcalibration.unlabeledTrackers"), true, this.font);
new TranslatableComponent("vivecraft.messages.fbtcalibration.unlabeledTrackers"), true, this.font);
this.unlabeledTrackersWarningText.visible = this.usingUnlabeledTrackers;

this.unlabeledTrackersConfirmationText = new MultilineComponent(this.width / 2, 30, 400,
Component.translatable("vivecraft.messages.fbtcalibration.unlabeledTrackersConfirm"), true, this.font);
new TranslatableComponent("vivecraft.messages.fbtcalibration.unlabeledTrackersConfirm"), true, this.font);
this.unlabeledTrackersConfirmationText.visible = false;

this.resetButton = new Button(this.width / 2 - 75, this.height - 54, 150, 20,
Component.translatable("controls.reset"), p -> reset());
new TranslatableComponent("controls.reset"), p -> reset());
this.resetButton.visible = this.calibrated;

this.cancelButton = new Button(this.width / 2 - 75, this.height - 32, 150, 20,
Component.translatable(this.calibrated ? "vivecraft.gui.ok" : "gui.cancel"),
new TranslatableComponent(this.calibrated ? "vivecraft.gui.ok" : "gui.cancel"),
p -> this.minecraft.setScreen(this.parent));

this.addRenderableWidget(this.calibrationText);
Expand Down Expand Up @@ -217,7 +217,8 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic
builder.vertex(poseStack.last().pose(), -4, 24, -100)
.color(1F, 1F, 1F, 1F).endVertex();

BufferUploader.drawWithShader(builder.end());
builder.end();
BufferUploader.end(builder);

if (VRState.VR_RUNNING) {
poseStack.mulPose(com.mojang.math.Vector3f.YP.rotation(
Expand Down Expand Up @@ -253,7 +254,8 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic
new Vec3(-6, 22, 0).add(this.rightHand.x * 10F, this.rightHand.y * 10F, this.rightHand.z * 10F),
4, 4, this.rightHandAtPosition ? colorActive : color, (byte) 200, poseStack);

BufferUploader.drawWithShader(builder.end());
builder.end();
BufferUploader.end(builder);

if (VRState.VR_RUNNING) {
ClientDataHolderVR.getInstance().vr.getInputAction(VivecraftVRMod.INSTANCE.keyVRInteract)
Expand All @@ -270,12 +272,12 @@ public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTic
ClientDataHolderVR.getInstance().vrSettings.unlabeledTrackersUsed = this.usingUnlabeledTrackers;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
this.minecraft.gui.getChat()
.addMessage(Component.translatable("vivecraft.messages.fbtcalibrationsuccess"));
.addMessage(new TranslatableComponent("vivecraft.messages.fbtcalibrationsuccess"));
this.calibrated = true;
if (!this.usingUnlabeledTrackers) {
this.minecraft.setScreen(this.parent);
} else {
this.cancelButton.setMessage(Component.translatable("vivecraft.gui.ok"));
this.cancelButton.setMessage(new TranslatableComponent("vivecraft.gui.ok"));
this.resetButton.visible = true;
}
}
Expand Down
Loading

0 comments on commit dbadda9

Please sign in to comment.