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 Feb 28, 2024
1 parent 38ce628 commit dc353aa
Show file tree
Hide file tree
Showing 21 changed files with 72 additions and 94 deletions.
14 changes: 7 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,27 @@ dependencies {


// 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.1.682") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:8.3.681") { 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" }

// other mods
modCompileOnly "maven.modrinth:dynamic-fps:3.4.2"
// modCompileOnly("com.simibubi.create:create-fabric-1.19.2:0.5.0.i-969+1.19.2")
// modCompileOnly "maven.modrinth:lithium:mc1.19.2-0.11.1"
// modCompileOnly "maven.modrinth:indium:1.0.9+mc1.19.2"
// modCompileOnly "maven.modrinth:lithium:mc1.18.2-0.10.3"
// modCompileOnly "maven.modrinth:indium:1.0.7+mc1.18.2"
modCompileOnly "maven.modrinth:resolution-control-plus:1.19.4-3.0.0"
modCompileOnly "maven.modrinth:better-combat:1.7.1+1.19-fabric"
modCompileOnly "maven.modrinth:better-combat:1.6.2+1.18.2-fabric"

// for immersive portals compat
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v2.3.1-1.19') { transitive false }
modCompileOnly('com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:v1.4.11-1.18') { transitive false }

//for epic fight compat
modCompileOnly("maven.modrinth:epic-fight:19.5.22")
modCompileOnly("maven.modrinth:epic-fight:18.5.22")

// needed dependencies
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class GuiVROptionSlider extends AbstractSliderButton implements GuiVROpti

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 @@ -34,7 +34,7 @@ public GuiVROptionSlider(int id, int x, int y, VRSettings.VrOptions option) {

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void init() {
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" + error.getString())));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.HoverEvent;
import net.minecraft.network.chat.*;
import org.jetbrains.annotations.NotNull;
import org.vivecraft.client.gui.widgets.TextScrollWidget;
import org.vivecraft.client_vr.ClientDataHolderVR;
Expand All @@ -22,31 +20,31 @@ public class GarbageCollectorScreen extends Screen {
private final static String guideURL = "https://github.com/Vivecraft/VivecraftMod/wiki/Memory-and-GC-Setup";

public GarbageCollectorScreen(String currentGarbageCollector) {
super(Component.translatable("vivecraft.messages.gctitle"));
super(new TranslatableComponent("vivecraft.messages.gctitle"));
this.lastScreen = Minecraft.getInstance().screen;
this.currentGarbageCollector = currentGarbageCollector;
}

protected void init() {
Component message = Component.translatable("vivecraft.messages.gcinfo",
Component.literal(currentGarbageCollector).withStyle(s -> s.withColor(ChatFormatting.RED)),
Component.literal("ZGC"),
Component.literal(Integer.toString(6)),
Component.literal("-XX:+UseZGC").withStyle(s -> s
Component message = new TranslatableComponent("vivecraft.messages.gcinfo",
new TextComponent(currentGarbageCollector).withStyle(s -> s.withColor(ChatFormatting.RED)),
new TextComponent("ZGC"),
new TextComponent(Integer.toString(6)),
new TextComponent("-XX:+UseZGC").withStyle(s -> s
.withColor(ChatFormatting.GOLD)
.withClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, "-XX:+UseZGC"))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.copy.click")))),
Component.translatable("vivecraft.gui.openguide").withStyle(style -> style
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.copy.click")))),
new TranslatableComponent("vivecraft.gui.openguide").withStyle(style -> style
.withUnderlined(true)
.withColor(ChatFormatting.GREEN)
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.translatable("chat.link.open")))
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TranslatableComponent("chat.link.open")))
.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, guideURL))));
this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 60, message));

this.addRenderableWidget(new Button(
this.width / 2 - 155, this.height - 56,
150, 20,
Component.translatable("vivecraft.gui.dontshowagain"),
new TranslatableComponent("vivecraft.gui.dontshowagain"),
(p) -> {
ClientDataHolderVR.getInstance().vrSettings.disableGarbageCollectorMessage = true;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
Expand All @@ -56,13 +54,13 @@ protected void init() {
this.addRenderableWidget(new Button(
this.width / 2 + 5, this.height - 56,
150, 20,
Component.translatable("vivecraft.gui.ok"),
new TranslatableComponent("vivecraft.gui.ok"),
(p) -> onClose()));

this.addRenderableWidget(new Button(
this.width / 2 - 75, this.height - 32,
150, 20,
Component.translatable("vivecraft.gui.openguide"),
new TranslatableComponent("vivecraft.gui.openguide"),
(p) -> {
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UpdateScreen extends Screen {
private TextScrollWidget text;

public UpdateScreen() {
super(Component.translatable("vivecraft.messages.updateTitle"));
super(new TranslatableComponent("vivecraft.messages.updateTitle"));
lastScreen = Minecraft.getInstance().screen;
}

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

this.addRenderableWidget(new Button(
this.width / 2 - 155, this.height - 56, 150, 20,
Component.translatable("vivecraft.gui.downloadfrom", Component.literal("Modrinth")),
new TranslatableComponent("vivecraft.gui.downloadfrom", new TextComponent("Modrinth")),
button ->
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Expand All @@ -42,7 +42,7 @@ protected void init() {

this.addRenderableWidget(new Button(
this.width / 2 + 5, this.height - 56, 150, 20,
Component.translatable("vivecraft.gui.downloadfrom", Component.literal("CurseForge")),
new TranslatableComponent("vivecraft.gui.downloadfrom", new TextComponent("CurseForge")),
button ->
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
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.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import org.vivecraft.client.gui.framework.GuiVROptionSlider;
import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.settings.VRSettings;
Expand Down Expand Up @@ -70,7 +72,7 @@ public static BaseEntry vrOptionToEntry(VRSettings.VrOptions option) {
tooltipPrefix = I18n.get("vivecraft.message.limitedbyserver", setting.getValueMin(), setting.getValueMax());
}
}
tooltip = Component.literal(tooltipPrefix + I18n.get(tooltipString, (Object) null));
tooltip = new TextComponent(tooltipPrefix + I18n.get(tooltipString, (Object) null));
} else {
tooltip = null;
}
Expand All @@ -95,10 +97,10 @@ public void renderButton(PoseStack poseStack, int x, int y, float f) {
// regular button
widget = new Button(
0, 0, WidgetEntry.valueButtonWidth, 20,
Component.literal(dh.vrSettings.getButtonDisplayString(option, true)),
new TextComponent(dh.vrSettings.getButtonDisplayString(option, true)),
button -> {
dh.vrSettings.setOptionValue(option);
button.setMessage(Component.literal(dh.vrSettings.getButtonDisplayString(option, true)));
button.setMessage(new TextComponent(dh.vrSettings.getButtonDisplayString(option, true)));
},
(button, poseStack, x, y) -> {
if (tooltip != null) {
Expand All @@ -107,7 +109,7 @@ public void renderButton(PoseStack poseStack, int x, int y, float f) {
});
}

BaseEntry entry = new WidgetEntry(Component.translatable(optionString), widget);
BaseEntry entry = new WidgetEntry(new TranslatableComponent(optionString), widget);
if (dh.vrSettings.overrides.hasSetting(option) && dh.vrSettings.overrides.getSetting(option).isValueOverridden()) {
entry.setActive(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TextScrollWidget extends AbstractWidget {
public TextScrollWidget(int x, int y, int width, int height, String text) {
super(x, y, width, height, new TextComponent(""));

formattedChars = Minecraft.getInstance().font.split(Component.literal(text), width - scrollBarWidth * 2);
formattedChars = Minecraft.getInstance().font.split(new TextComponent(text), width - scrollBarWidth * 2);

initScroll();
}
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/java/org/vivecraft/client_vr/VRState.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import org.apache.commons.lang3.StringUtils;
import org.lwjgl.glfw.GLFW;
import org.vivecraft.client.gui.screens.ErrorScreen;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ public void doProcess(LocalPlayer player) {
|| item.useOn(new UseOnContext(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockHit)).shouldSwing())) {
// don't try to break crops with hoes
// actually use the item on the block
boolean useSuccessful = this.mc.gameMode.useItemOn(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockHit).shouldSwing();
boolean useSuccessful = this.mc.gameMode.useItemOn(player, (ClientLevel) player.level, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockHit).shouldSwing();
if (itemstack.is(ItemTags.VIVECRAFT_SCYTHES) && !useSuccessful) {
// some scythes just need to be used
this.mc.gameMode.useItem(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
this.mc.gameMode.useItem(player, player.level, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
}
}
// roomscale noteblocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ private void checkPathValid(String path, String knownError, boolean alwaysThrow)
if (hasInvalidChars || alwaysThrow) {
String error = knownError + (hasInvalidChars ? "\nInvalid characters in path: \n" : "\n");
System.out.println(error + path);
throw new RenderConfigException(knownError, Component.empty().append(error).append(pathFormatted));
throw new RenderConfigException(knownError, new TextComponent(error).append(pathFormatted));
}
}

Expand Down Expand Up @@ -980,7 +980,7 @@ private void loadActionManifest() throws RenderConfigException {
int i = VRInput_SetActionManifestPath(actionsPath);

if (i != 0) {
throw new RenderConfigException("Failed to load action manifest", Component.literal(getInputErrorName(i)));
throw new RenderConfigException("Failed to load action manifest", new TextComponent(getInputErrorName(i)));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected TitleScreenMixin(Component component) {
vivecraft$updateButton.visible = UpdateChecker.hasUpdate;

if (vivecraft$vrModeButton.visible && vivecraft$vrModeButton.isMouseOver(i, j)) {
renderTooltip(poseStack, font.split(Component.translatable("vivecraft.options.VR_ENABLED.tooltip"), Math.max(width / 2 - 43, 170)), i, j);
renderTooltip(poseStack, font.split(new TranslatableComponent("vivecraft.options.VR_ENABLED.tooltip"), Math.max(width / 2 - 43, 170)), i, j);
}
if (VRState.vrInitialized && !VRState.vrRunning) {
Component hotswitchMessage = new TranslatableComponent("vivecraft.messages.vrhotswitchinginfo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
}
}

@Inject(at = @At("TAIL"), method = "lambda$new$2", remap = false, require = 0, expect = 0)
@Inject(at = @At("TAIL"), method = "lambda$new$1", remap = false, require = 0, expect = 0)
private void vivecraft$showGarbageCollectorScreenForge(CallbackInfo ci) {
if ("forge".equals(Xplat.getModloader())) {
vivecraft$showGarbageCollectorScreen();
Expand Down Expand Up @@ -777,11 +777,7 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
for (int i = 0; i < VivecraftVRMod.INSTANCE.keyQuickCommands.length; i++) {
if (VivecraftVRMod.INSTANCE.keyQuickCommands[i].consumeClick()) {
String command = ClientDataHolderVR.getInstance().vrSettings.vrQuickCommands[i];
if (command.startsWith("/")) {
this.player.commandSigned(command.substring(1), Component.empty());
} else {
this.player.chatSigned(command, Component.empty());
}
this.player.chat(command);
}
}
}
Expand Down Expand Up @@ -958,7 +954,7 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
Minecraft.getInstance().getSoundManager().reload();
}
resizeDisplay();
window.updateVsync(options.enableVsync().get());
window.updateVsync(options.enableVsync);
}

@Unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ public CreativeModeInventoryScreenVRMixin(CreativeModeInventoryScreen.ItemPicker

if (tab == CreativeModeTab.TAB_TOOLS || tab == null) {
ItemStack boots = new ItemStack(Items.LEATHER_BOOTS);
boots.setHoverName(Component.translatable("vivecraft.item.jumpboots"));
boots.setHoverName(new TranslatableComponent("vivecraft.item.jumpboots"));
boots.getTag().putBoolean("Unbreakable", true);
boots.getTag().putInt("HideFlags", 4);
boots.getOrCreateTagElement(ItemStack.TAG_DISPLAY).putInt(ItemStack.TAG_COLOR, 9233775);

ItemStack claws = new ItemStack(Items.SHEARS);
claws.setHoverName(Component.translatable("vivecraft.item.climbclaws"));
claws.setHoverName(new TranslatableComponent("vivecraft.item.climbclaws"));
claws.getTag().putBoolean("Unbreakable", true);
claws.getTag().putInt("HideFlags", 4);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public class ShapedRecipeMixin {
} else {
ItemStack itemStack = new ItemStack(vanillaItem, i);
if (jsonObject.has("fallbackname")) {
itemStack.setHoverName(Component.translatable(
itemStack.setHoverName(new TranslatableComponent(
jsonObject.get("name").getAsString()));
} else {
itemStack.setHoverName(Component.translatable(jsonObject.get("name").getAsString()));
itemStack.setHoverName(new TranslatableComponent(jsonObject.get("name").getAsString()));
}
itemStack.getOrCreateTag().putBoolean("Unbreakable", GsonHelper.getAsBoolean(jsonObject, "unbreakable", false));
itemStack.getOrCreateTag().putInt("HideFlags", GsonHelper.getAsInt(jsonObject, "hideflags", 0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
}
} else {
// unsupported version, send notification, and disregard
player.sendSystemMessage(Component.literal("Unsupported vivecraft version, VR features will not work"));
player.sendMessage(new TextComponent("Unsupported vivecraft version, VR features will not work"), Util.NIL_UUID);
if (ServerConfig.debug.get()) {
LOGGER.info("{} networking not supported. client range [{},{}], server range [{},{}]",
player.getName().getString(),
Expand Down
Loading

0 comments on commit dc353aa

Please sign in to comment.