Skip to content

Commit

Permalink
1.19 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
thejudge156 committed Sep 3, 2023
1 parent 325bab5 commit ad71521
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public class GuiFreeMoveSettings extends GuiVROptionsBase
VRSettings.VrOptions.FREEMOVE_MODE,
VRSettings.VrOptions.FREEMOVE_FLY_MODE,
VRSettings.VrOptions.FOV_REDUCTION,
VRSettings.VrOptions.INERTIA_FACTOR,
VRSettings.VrOptions.MOVEMENT_MULTIPLIER,
VRSettings.VrOptions.AUTO_SPRINT,
VRSettings.VrOptions.AUTO_SPRINT_THRESHOLD,
Expand All @@ -21,7 +20,6 @@ public class GuiFreeMoveSettings extends GuiVROptionsBase
private static VRSettings.VrOptions[] seatedSettings = new VRSettings.VrOptions[] {
VRSettings.VrOptions.SEATED_HMD,
VRSettings.VrOptions.FOV_REDUCTION,
VRSettings.VrOptions.INERTIA_FACTOR
};
private static VRSettings.VrOptions[] fovRed = new VRSettings.VrOptions[] {
VRSettings.VrOptions.FOV_REDUCTION_MIN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ public class GuiMainVRSettings extends GuiVROptionsBase
new VROptionLayout(GuiOtherHUDSettings.class, VROptionLayout.Position.POS_RIGHT, 2.0F, true, "vivecraft.options.screen.guiother.button"),
new VROptionLayout(VRSettings.VrOptions.WORLD_SCALE, VROptionLayout.Position.POS_LEFT, 6.0F, true, (String)null),
new VROptionLayout(VRSettings.VrOptions.WORLD_ROTATION, VROptionLayout.Position.POS_RIGHT, 6.0F, true, (String)null),
new VROptionLayout(VRSettings.VrOptions.PLAY_MODE_SEATED, (button, mousePos) -> {
this.reinit = true;

if (!this.dataholder.vrSettings.seated)
{
this.isConfirm = true;
return true;
}
else {
return false;
}
}, VROptionLayout.Position.POS_LEFT, 0.0F, true, (String)null),
new VROptionLayout(VRSettings.VrOptions.VR_HOTSWITCH, VROptionLayout.Position.POS_RIGHT, 0.0F, true, (String)null),
new VROptionLayout(VRSettings.VrOptions.LOW_HEALTH_INDICATOR, VROptionLayout.Position.POS_RIGHT, 7.0F, true, (String)null)
};
private VROptionLayout[] vrStandingOptions = new VROptionLayout[] {
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/org/vivecraft/client_vr/VRState.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void initializeVR() {
dh.menuWorldRenderer.init();
} catch (RenderConfigException renderConfigException) {
vrEnabled = false;
destroyVR(true);
destroyVR(false);
Minecraft.getInstance().setScreen(new ErrorScreen(renderConfigException.title, renderConfigException.error));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ public enum ChatServerPluginMessage implements OptionEnum<VRProvider> {
@SettingField(VrOptions.SHOW_PLUGIN_MISSING)
public boolean showServerPluginMissingMessageAlways = true;
@SettingField
public boolean vrEnabled = false;
public boolean vrEnabled = true;
@SettingField(VrOptions.VR_HOTSWITCH)
public boolean vrHotswitchingEnabled = true;
public boolean vrHotswitchingEnabled = false;

/**
* This isn't actually used, it's only a dummy field to save the value from vanilla Options.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,64 +25,10 @@ protected TitleScreenMixin(Component component) {
// private final Properties vrConfig = new Properties();
// private final Path vrConfigPath = Xplat.getConfigPath("vivecraft-config.properties");
private boolean showError = false;
private Button vrModeButton;

private Button updateButton;

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screens/TitleScreen;addRenderableWidget(Lnet/minecraft/client/gui/components/events/GuiEventListener;)Lnet/minecraft/client/gui/components/events/GuiEventListener;", shift = At.Shift.AFTER, ordinal = 1), method = "createNormalMenuOptions")
public void initFullGame(CallbackInfo ci) {
addVRModeButton();
}

@Inject(at = @At("TAIL"), method = "createDemoMenuOptions")
public void initDemo(CallbackInfo ci) {
addVRModeButton();
}

private void addVRModeButton() {

vrModeButton = new Button(
this.width / 2 + 104, this.height / 4 + 72,
56, 20,
Component.translatable("vivecraft.gui.vr", getIcon() , VRState.vrEnabled ? CommonComponents.OPTION_ON : CommonComponents.OPTION_OFF),
(button) -> {
showError = false;
VRState.vrEnabled = !VRState.vrEnabled;
ClientDataHolderVR.getInstance().vrSettings.vrEnabled = VRState.vrEnabled;
ClientDataHolderVR.getInstance().vrSettings.saveOptions();
button.setMessage(Component.translatable("vivecraft.gui.vr", getIcon(), VRState.vrEnabled ? CommonComponents.OPTION_ON : CommonComponents.OPTION_OFF));
});

this.addRenderableWidget(vrModeButton);

updateButton = new Button(
this.width / 2 + 104, this.height / 4 + 96,
56, 20,
Component.translatable("vivecraft.gui.update"),
(button) -> minecraft.setScreen(new UpdateScreen()));

updateButton.visible = UpdateChecker.hasUpdate;

this.addRenderableWidget(updateButton);
}

private String getIcon() {
return (showError ? "§c\u26A0§r " : "");
}

@Inject(at = @At("TAIL"), method = "render")
public void renderToolTip(PoseStack poseStack, int i, int j, float f, CallbackInfo ci) {
updateButton.visible = UpdateChecker.hasUpdate;

if (vrModeButton.isMouseOver(i, j)) {
renderTooltip(poseStack, font.split(Component.translatable("vivecraft.options.VR_MODE.tooltip"), Math.max(width / 2 - 43, 170)), i, j);
}
if (VRState.vrInitialized && !VRState.vrRunning) {
Component hotswitchMessage = Component.translatable("vivecraft.messages.vrhotswitchinginfo");
renderTooltip(poseStack, font.split(hotswitchMessage, 280), width / 2 - 140 - 12, 17);
}
}

@Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/PanoramaRenderer;render(FF)V"), method = "render")
public void maybeNoPanorama(PanoramaRenderer instance, float f, float g){
if (VRState.vrRunning && ClientDataHolderVR.getInstance().menuWorldRenderer.isReady()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public void replaceTick(boolean bl, CallbackInfo callback) {
if (VRState.vrEnabled) {
VRState.initializeVR();
} else if (VRState.vrInitialized) {
VRState.destroyVR(true);
VRState.destroyVR(false);
resizeDisplay();
}
if (!VRState.vrInitialized) {
Expand Down Expand Up @@ -695,7 +695,7 @@ public void preRender(boolean tick) {
} catch (RenderConfigException renderConfigException) {
// TODO: could disabling VR here cause issues?
Minecraft.getInstance().setScreen(new ErrorScreen("VR Render Error", Component.translatable("vivecraft.messages.rendersetupfailed", renderConfigException.error + "\nVR provider: " + ClientDataHolderVR.getInstance().vr.getName())));
VRState.destroyVR(true);
VRState.destroyVR(false);
return;
} catch (Exception exception2) {
exception2.printStackTrace();
Expand Down

0 comments on commit ad71521

Please sign in to comment.