Skip to content

Commit

Permalink
1.18.2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fayer3 committed Oct 9, 2023
1 parent e301ed5 commit ddcf3cd
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion common/src/main/java/org/vivecraft/server/ServerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public static void registerCommands(CommandDispatcher<net.minecraft.commands.Com
try {
Object newValue = context.getArgument(argumentName, clazz);
setting.set(newValue);
context.getSource().sendSystemMessage(Component.literal("set §a[" + setting.getPath() + "]§r to '" + newValue + "'"));
context.getSource().sendSuccess(new TextComponent("set §a[" + setting.getPath() + "]§r to '" + newValue + "'"), true);
} catch (Exception e) {
e.printStackTrace();
}
Expand Down
33 changes: 17 additions & 16 deletions common/src/main/java/org/vivecraft/server/config/WidgetBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.*;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import org.vivecraft.client.gui.settings.GuiListValueEditScreen;

import java.util.function.Supplier;
Expand All @@ -12,24 +13,24 @@ public class WidgetBuilder {
public static Supplier<AbstractWidget> getBaseWidget(ConfigBuilder.ConfigValue<?> value, int width, int height) {
return () -> new Button(
0, 0, width, height,
Component.literal("" + value.get()),
new TextComponent("" + value.get()),
button -> {
},
((button, poseStack, x, y) ->
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(Component.literal(value.getComment()), 200), x, y)));
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(new TextComponent(value.getComment()), 200), x, y)));
}

public static Supplier<AbstractWidget> getOnOffWidget(ConfigBuilder.BooleanValue booleanValue, int width, int height) {
return () -> CycleButton
.onOffBuilder(booleanValue.get())
.displayOnlyValue()
.withTooltip((bool) -> booleanValue.getComment() != null ? Minecraft.getInstance().font.split(Component.literal(booleanValue.getComment()), 200) : null)
.create(0, 0, width, height, Component.empty(), (button, bool) -> booleanValue.set(bool));
.withTooltip((bool) -> booleanValue.getComment() != null ? Minecraft.getInstance().font.split(new TextComponent(booleanValue.getComment()), 200) : null)
.create(0, 0, width, height, TextComponent.EMPTY, (button, bool) -> booleanValue.set(bool));
}

public static Supplier<AbstractWidget> getEditBoxWidget(ConfigBuilder.StringValue stringValue, int width, int height) {
return () -> {
EditBox box = new EditBox(Minecraft.getInstance().font, 0, 0, width - 1, height, Component.literal(stringValue.get())) {
EditBox box = new EditBox(Minecraft.getInstance().font, 0, 0, width - 1, height, new TextComponent(stringValue.get())) {
@Override
public boolean charTyped(char c, int i) {
boolean ret = super.charTyped(c, i);
Expand All @@ -48,7 +49,7 @@ public boolean keyPressed(int i, int j, int k) {
public void renderButton(PoseStack poseStack, int x, int y, float f) {
super.renderButton(poseStack, x, y, f);
if (this.isHovered) {
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(Component.literal(stringValue.getComment()), 200), x, y);
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(new TextComponent(stringValue.getComment()), 200), x, y);
}
}
};
Expand All @@ -60,21 +61,21 @@ public void renderButton(PoseStack poseStack, int x, int y, float f) {

public static <T> Supplier<AbstractWidget> getCycleWidget(ConfigBuilder.InListValue<T> inListValue, int width, int height) {
return () -> CycleButton
.builder((newValue) -> Component.literal("" + newValue))
.builder((newValue) -> new TextComponent("" + newValue))
.withInitialValue(inListValue.get())
// toArray is needed here, because the button uses Objects, and the collection is of other types
.withValues(inListValue.getValidValues().toArray())
.displayOnlyValue()
.withTooltip((bool) -> inListValue.getComment() != null ? Minecraft.getInstance().font.split(Component.literal(inListValue.getComment()), 200) : null)
.create(0, 0, width, height, Component.empty(), (button, newValue) -> inListValue.set((T) newValue));
.withTooltip((bool) -> inListValue.getComment() != null ? Minecraft.getInstance().font.split(new TextComponent(inListValue.getComment()), 200) : null)
.create(0, 0, width, height, TextComponent.EMPTY, (button, newValue) -> inListValue.set((T) newValue));
}

public static <E extends Number> Supplier<AbstractWidget> getSliderWidget(ConfigBuilder.NumberValue<E> numberValue, int width, int height) {
return () -> {
AbstractSliderButton widget = new AbstractSliderButton(0, 0, width, height, Component.literal("" + numberValue.get()), numberValue.normalize()) {
AbstractSliderButton widget = new AbstractSliderButton(0, 0, width, height, new TextComponent("" + numberValue.get()), numberValue.normalize()) {
@Override
protected void updateMessage() {
setMessage(Component.literal("" + numberValue.get()));
setMessage(new TextComponent("" + numberValue.get()));
}

@Override
Expand All @@ -86,7 +87,7 @@ protected void applyValue() {
public void renderButton(PoseStack poseStack, int x, int y, float f) {
super.renderButton(poseStack, x, y, f);
if (this.isHovered) {
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(Component.literal(numberValue.getComment()), 200), x, y);
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(new TextComponent(numberValue.getComment()), 200), x, y);
}
}
};
Expand All @@ -98,12 +99,12 @@ public static <T> Supplier<AbstractWidget> getEditListWidget(ConfigBuilder.ListV
// TODO handle other types than String
return () -> new Button(
0, 0, width, height,
Component.translatable("vivecraft.options.editlist"),
new TranslatableComponent("vivecraft.options.editlist"),
button -> Minecraft.getInstance()
.setScreen(
new GuiListValueEditScreen(Component.literal(listValue.getPath().substring(listValue.getPath().lastIndexOf("."))), Minecraft.getInstance().screen, (ConfigBuilder.ListValue<String>) listValue)
new GuiListValueEditScreen(new TextComponent(listValue.getPath().substring(listValue.getPath().lastIndexOf("."))), Minecraft.getInstance().screen, (ConfigBuilder.ListValue<String>) listValue)
),
(button, poseStack, x, y) ->
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(Component.literal(listValue.getComment()), 200), x, y));
Minecraft.getInstance().screen.renderTooltip(poseStack, Minecraft.getInstance().font.split(new TextComponent(listValue.getComment()), 200), x, y));
}
}
1 change: 0 additions & 1 deletion forge/src/main/java/org/vivecraft/forge/Vivecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ public Vivecraft() {
() -> NetworkConstants.IGNORESERVERONLY, // only needed on server, client is optional
(s, b) -> true // any version is good
));

}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.vivecraft.forge.event;

import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.client.ConfigGuiHandler;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ForgeModelBakery;
import net.minecraftforge.eventbus.api.SubscribeEvent;
Expand All @@ -27,6 +27,6 @@ public static void registerModels(ModelRegistryEvent event) {

@SubscribeEvent
public static void registerConfigScreen(FMLConstructModEvent constructModEvent) {
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new VivecraftMainSettings(screen)));
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class, () -> new ConfigGuiHandler.ConfigGuiFactory((mc, screen) -> new VivecraftMainSettings(screen)));
}
}
2 changes: 1 addition & 1 deletion forge/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"pack": {
"description": "The VR mod for any loader!",
"pack_format": 10
"pack_format": 9
}
}

0 comments on commit ddcf3cd

Please sign in to comment.