Skip to content

Commit

Permalink
backport to 1.19.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Feb 28, 2024
1 parent 9096414 commit 0b9d485
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 106 deletions.
17 changes: 9 additions & 8 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,31 @@ 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.4-0.4.10"
modCompileOnly "maven.modrinth:sodium:mc1.19.2-0.4.4"
modCompileOnly 'org.joml:joml:1.10.4'

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

// for REI compat
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:11.0.683") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" exclude group: "dev.architectury" }
modCompileOnly("me.shedaniel:RoughlyEnoughItems-fabric:9.1.682") { 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.4-0.11.1"
// modCompileOnly "maven.modrinth:indium:1.0.19+mc1.19.4"
// modCompileOnly "maven.modrinth:lithium:mc1.19.2-0.11.1"
// modCompileOnly "maven.modrinth:indium:1.0.9+mc1.19.2"
modCompileOnly "maven.modrinth:resolution-control-plus:1.19.4-3.0.0"
modCompileOnly "maven.modrinth:better-combat:1.7.1+1.19.4-fabric"
modCompileOnly "maven.modrinth:better-combat:1.7.1+1.19-fabric"

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

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

// needed dependencies
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/org/vivecraft/MixinConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.mod_compat_vr.iris.mixin.coderbot.IrisChunkProgramOverridesMixinSodium_0_4_11;
import org.vivecraft.mod_compat_vr.iris.mixin.coderbot.IrisChunkProgramOverridesMixinSodium_0_4_8;
import org.vivecraft.mod_compat_vr.iris.mixin.coderbot.IrisChunkProgramOverridesMixinSodium_0_4_9;
import org.vivecraft.mod_compat_vr.iris.mixin.irisshaders.IrisChunkProgramOverridesMixinSodium_0_6;
import org.vivecraft.mod_compat_vr.sodium.SodiumHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,6 @@ public boolean charTyped(char pCodePoint, int pModifiers) {
private void renderTooltip(PoseStack pMatrixStack, int pMouseX, int pMouseY) {
GuiEventListener hover = null;

if (this.minecraft.getLastInputType().isKeyboard()) {
// only show focused tooltip when navigating with keyboard, so a click with the mouse removes it
hover = this.getFocused();
}
// find active button
if (hover == null) {
for (GuiEventListener child : children()) {
Expand Down Expand Up @@ -323,6 +319,6 @@ private void renderTooltip(PoseStack pMatrixStack, int pMouseX, int pMouseY) {
}

private boolean isMouseOver(AbstractWidget widget, double x, double y) {
return widget.visible && x >= widget.getX() && y >= widget.getY() && x < (widget.getX() + widget.getWidth()) && y < (widget.getY() + widget.getHeight());
return widget.visible && x >= widget.x && y >= widget.y && x < (widget.x + widget.getWidth()) && y < (widget.y + widget.getHeight());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ protected void init() {

text = this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 36, error));

this.addRenderableWidget(new Button.Builder(Component.translatable("gui.back"), (p) ->
Minecraft.getInstance().setScreen(this.lastScreen))
.pos(this.width / 2 + 5, this.height - 32)
.size(150, 20)
.build());
this.addRenderableWidget(new Button.Builder(Component.translatable("chat.copy.click"), (p) ->
Minecraft.getInstance().keyboardHandler.setClipboard(this.title.getString() + "\n" + error.getString()))
.pos(this.width / 2 - 155, this.height - 32)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 + 5, this.height - 32,
150, 20,
Component.translatable("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"),
(p) -> Minecraft.getInstance().keyboardHandler.setClipboard(this.title.getString() + "\n" + error.getString())));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
Expand Down Expand Up @@ -42,26 +43,34 @@ protected void init() {
.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.Builder(Component.translatable("vivecraft.gui.dontshowagain"), (p) -> {
ClientDataHolderVR.getInstance().vrSettings.disableGarbageCollectorMessage = true;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
Minecraft.getInstance().setScreen(this.lastScreen);
})
.pos(this.width / 2 - 155, this.height - 56)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 - 155, this.height - 56,
150, 20,
Component.translatable("vivecraft.gui.dontshowagain"),
(p) -> {
ClientDataHolderVR.getInstance().vrSettings.disableGarbageCollectorMessage = true;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
Minecraft.getInstance().setScreen(this.lastScreen);
}));

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.ok"), (p) ->
onClose())
.pos(this.width / 2 + 5, this.height - 56)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 + 5, this.height - 56,
150, 20,
Component.translatable("vivecraft.gui.ok"),
(p) -> onClose()));

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.openguide"),
ConfirmLinkScreen.confirmLink(guideURL, this, true))
.pos(this.width / 2 - 75, this.height - 32)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 - 75, this.height - 32,
150, 20,
Component.translatable("vivecraft.gui.openguide"),
(p) -> {
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Util.getPlatform().openUri(guideURL);
}
this.minecraft.setScreen(this);
}, guideURL, true));
}));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,29 @@ protected void init() {

text = this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 60, UpdateChecker.changelog));

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.downloadfrom", Component.literal("Modrinth")),
ConfirmLinkScreen.confirmLink("https://modrinth.com/mod/vivecraft", this, true))
.pos(this.width / 2 - 155, this.height - 56)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 - 155, this.height - 56, 150, 20,
Component.translatable("vivecraft.gui.downloadfrom", Component.literal("Modrinth")),
button ->
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Util.getPlatform().openUri("https://modrinth.com/mod/vivecraft");
}
this.minecraft.setScreen(this);
}, "https://modrinth.com/mod/vivecraft", true))
));

this.addRenderableWidget(new Button.Builder(Component.translatable("vivecraft.gui.downloadfrom", Component.literal("CurseForge")),
ConfirmLinkScreen.confirmLink("https://www.curseforge.com/minecraft/mc-mods/vivecraft", this, true))
.pos(this.width / 2 + 5, this.height - 56)
.size(150, 20)
.build());
this.addRenderableWidget(new Button(
this.width / 2 + 5, this.height - 56, 150, 20,
Component.translatable("vivecraft.gui.downloadfrom", Component.literal("CurseForge")),
button ->
this.minecraft.setScreen(new ConfirmLinkScreen(bl -> {
if (bl) {
Util.getPlatform().openUri("https://www.curseforge.com/minecraft/mc-mods/vivecraft");
}
this.minecraft.setScreen(this);
}, "https://www.curseforge.com/minecraft/mc-mods/vivecraft", true))
));

this.addRenderableWidget(new Button(
this.width / 2 - 75, this.height - 32,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@ protected List<SettingsList.BaseEntry> getEntries() {

entries.add(new SettingsList.WidgetEntry(
Component.translatable("vivecraft.options.screen.main"),
Button.builder(Component.translatable("vivecraft.options.screen.main"), button -> this.minecraft.setScreen(new GuiMainVRSettings(this)))
.size(SettingsList.WidgetEntry.valueButtonWidth, 20)
.build()
new Button(
0, 0, SettingsList.WidgetEntry.valueButtonWidth, 20,
Component.translatable("vivecraft.options.screen.main"),
button -> this.minecraft.setScreen(new GuiMainVRSettings(this)))
));

entries.add(new SettingsList.WidgetEntry(
Component.translatable("vivecraft.options.screen.server"),
Button.builder(Component.translatable("vivecraft.options.screen.server"), button -> this.minecraft.setScreen(new GuiServerSettings(this)))
.size(SettingsList.WidgetEntry.valueButtonWidth, 20)
.build()
new Button(
0, 0, SettingsList.WidgetEntry.valueButtonWidth, 20,
Component.translatable("vivecraft.options.screen.server"),
button -> this.minecraft.setScreen(new GuiServerSettings(this)))
));

entries.add(new SettingsList.CategoryEntry(Component.literal("Vivecraft Buttons")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static BaseEntry vrOptionToEntry(VRSettings.VrOptions option) {
ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
String optionString = "vivecraft.options." + option.name();
String tooltipString = optionString + ".tooltip";
Tooltip tooltip;
Component tooltip;
// check if it has a tooltip
if (I18n.exists(tooltipString)) {
String tooltipPrefix = "";
Expand All @@ -70,7 +70,7 @@ public static BaseEntry vrOptionToEntry(VRSettings.VrOptions option) {
tooltipPrefix = I18n.get("vivecraft.message.limitedbyserver", setting.getValueMin(), setting.getValueMax());
}
}
tooltip = Tooltip.create(Component.literal(tooltipPrefix + I18n.get(tooltipString, (Object) null)));
tooltip = Component.literal(tooltipPrefix + I18n.get(tooltipString, (Object) null));
} else {
tooltip = null;
}
Expand All @@ -82,18 +82,29 @@ public static BaseEntry vrOptionToEntry(VRSettings.VrOptions option) {
widget = new GuiVROptionSlider(option.returnEnumOrdinal(),
0, 0,
WidgetEntry.valueButtonWidth, 20,
option, true);
widget.setTooltip(tooltip);
option, true) {
@Override
public void renderButton(PoseStack poseStack, int x, int y, float f) {
super.renderButton(poseStack, x, y, f);
if (this.isHovered && tooltip != null) {
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(tooltip, 200), x, y);
}
}
};
} else {
// regular button
widget = Button.builder(Component.literal(dh.vrSettings.getButtonDisplayString(option, true))
, button -> {
dh.vrSettings.setOptionValue(option);
button.setMessage(Component.literal(dh.vrSettings.getButtonDisplayString(option, true)));
})
.size(WidgetEntry.valueButtonWidth, 20)
.tooltip(tooltip)
.build();
widget = new Button(
0, 0, WidgetEntry.valueButtonWidth, 20,
Component.literal(dh.vrSettings.getButtonDisplayString(option, true)),
button -> {
dh.vrSettings.setOptionValue(option);
button.setMessage(Component.literal(dh.vrSettings.getButtonDisplayString(option, true)));
},
(button, poseStack, x, y) -> {
if (tooltip != null) {
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(tooltip, 200), x, y);
}
});
}

BaseEntry entry = new WidgetEntry(Component.translatable(optionString), widget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public static boolean isTool(Item item) {
item == Items.STICK ||
item == Items.DEBUG_STICK ||
item instanceof FlintAndSteelItem ||
item instanceof BrushItem ||
item.getDefaultInstance().is(ItemTags.VIVECRAFT_TOOLS);
}

Expand Down Expand Up @@ -226,7 +225,7 @@ public void doProcess(LocalPlayer player) {
continue;
}

BlockPos blockpos = BlockPos.containing(this.miningPoint[c]);
BlockPos blockpos = new BlockPos(this.miningPoint[c]);
BlockState blockstate = this.mc.level.getBlockState(blockpos);

// every time end of weapon enters a solid for the first time, trace from our previous air position
Expand Down Expand Up @@ -263,12 +262,6 @@ public void doProcess(LocalPlayer player) {
this.mc.gameMode.useItem(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
}
}
// roomscale brushes
else if ((item instanceof BrushItem /*|| itemstack.is(ItemTags.VIVECRAFT_BRUSHES*/)) {
((BrushItem) item).spawnDustParticles(player.level, blockHit, blockstate, player.getViewVector(0.0F));
player.level.playSound(player, blockHit.getBlockPos(), SoundEvents.BRUSH_BRUSHING, SoundSource.PLAYERS);
this.mc.gameMode.useItemOn(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockHit);
}
// roomscale noteblocks
else if (blockstate.getBlock() instanceof NoteBlock || blockstate.is(BlockTags.VIVECRAFT_MUSIC_BLOCKS)) {
this.mc.gameMode.continueDestroyBlock(blockHit.getBlockPos(), blockHit.getDirection());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.player.RemotePlayer;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -21,7 +21,7 @@
@Mixin(ItemInHandLayer.class)
public abstract class ItemInHandLayerMixin {
@ModifyVariable(at = @At("HEAD"), method = "renderArmWithItem", argsOnly = true)
private ItemStack vivecraft$climbClawsOverride(ItemStack itemStack, LivingEntity livingEntity, ItemStack itemStack2, ItemDisplayContext itemDisplayContext, HumanoidArm humanoidArm) {
private ItemStack vivecraft$climbClawsOverride(ItemStack itemStack, LivingEntity livingEntity, ItemStack itemStack2, ItemTransforms.TransformType transformType, HumanoidArm humanoidArm) {
ClimbTracker tracker = ClientDataHolderVR.getInstance().climbTracker;
if (ClientNetworking.serverAllowsClimbey && livingEntity instanceof Player && !tracker.isClaws(itemStack)) {
ItemStack otherStack = humanoidArm == livingEntity.getMainArm() ? livingEntity.getOffhandItem() : livingEntity.getMainHandItem();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
vivecraft$showGarbageCollectorScreen();
}
}

@Inject(at = @At("TAIL"), method = "lambda$new$2", remap = false, require = 0, expect = 0)
private void vivecraft$showGarbageCollectorScreenForge(CallbackInfo ci) {
if ("forge".equals(Xplat.getModloader())) {
Expand Down Expand Up @@ -773,9 +774,9 @@ public abstract class MinecraftVRMixin implements MinecraftExtension {
if (VivecraftVRMod.INSTANCE.keyQuickCommands[i].consumeClick()) {
String command = ClientDataHolderVR.getInstance().vrSettings.vrQuickCommands[i];
if (command.startsWith("/")) {
this.player.connection.sendCommand(command.substring(1));
this.player.commandSigned(command.substring(1), Component.empty());
} else {
this.player.connection.sendChat(command);
this.player.chatSigned(command, Component.empty());
}
}
}
Expand Down
Loading

0 comments on commit 0b9d485

Please sign in to comment.