Search in sources :

Example 1 with IModelRenderer

use of com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer in project Multiblocked by Low-Drag-MC.

the class MBDIModelRenderer method createConfigurator.

@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
    TextFieldWidget tfw = new TextFieldWidget(1, 1, 150, 20, null, null);
    group.addWidget(tfw);
    File path = new File(Multiblocked.location, "assets/multiblocked/models");
    group.addWidget(new ButtonWidget(155, 1, 20, 20, cd -> DialogWidget.showFileDialog(parent, "select a java model", path, true, DialogWidget.suffixFilter(".json"), r -> {
        if (r != null && r.isFile()) {
            tfw.setCurrentString("multiblocked:" + r.getPath().replace(path.getPath(), "").substring(1).replace(".json", "").replace('\\', '/'));
        }
    })).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/darkened_slot.png"), new TextTexture("F", -1)).setHoverTooltips("multiblocked.gui.tips.file_selector"));
    if (current instanceof IModelRenderer && ((IModelRenderer) current).modelLocation != null) {
        tfw.setCurrentString(((IModelRenderer) current).modelLocation.toString());
    }
    return () -> {
        if (tfw.getCurrentString().isEmpty()) {
            return null;
        } else {
            return new MBDIModelRenderer(new ResourceLocation(tfw.getCurrentString()));
        }
    };
}
Also used : JsonObject(com.google.gson.JsonObject) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) IModelRenderer(com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer) Supplier(java.util.function.Supplier) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) Gson(com.google.gson.Gson) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) IModelRenderer(com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer) File(java.io.File) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Aggregations

Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 IModelRenderer (com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer)1 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)1 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)1 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)1 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)1 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)1 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)1 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)1 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)1 IMultiblockedRenderer (com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer)1 File (java.io.File)1 Supplier (java.util.function.Supplier)1 ResourceLocation (net.minecraft.util.ResourceLocation)1