Search in sources :

Example 1 with CreatePartWidget

use of com.lowdragmc.multiblocked.common.gui.component.CreatePartWidget in project Multiblocked by Low-Drag-MC.

the class PartBuilderWidget method updateList.

protected void updateList() {
    setNewRenderer(null, "");
    files.forEach(containers::waitToRemoved);
    files.clear();
    File path = new File(Multiblocked.location, "definition/part");
    walkFile("Common", new ItemStackTexture(BlueprintTableTileEntity.partDefinition.getStackForm()), path, (jsonElement, file) -> {
        PartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, PartDefinition.class);
        new PartWidget(this, definition, jsonObject -> {
            if (jsonObject != null) {
                FileUtility.saveJson(file, jsonObject);
            }
        });
    });
    if (Multiblocked.isCreateLoaded()) {
        path = new File(path, "create");
        walkFile("Create", new ItemStackTexture(AllBlocks.FLYWHEEL.asStack()), path, ((jsonElement, file) -> {
            CreatePartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, CreatePartDefinition.class);
            new CreatePartWidget(this, definition, jsonObject -> {
                if (jsonObject != null) {
                    FileUtility.saveJson(file, jsonObject);
                }
            });
        }));
    }
}
Also used : OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) CreatePartDefinition(com.lowdragmc.multiblocked.common.definition.CreatePartDefinition) CreatePartWidget(com.lowdragmc.multiblocked.common.gui.component.CreatePartWidget) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) BlueprintTableTileEntity(com.lowdragmc.multiblocked.api.tile.BlueprintTableTileEntity) Dist(net.minecraftforge.api.distmarker.Dist) ArrayList(java.util.ArrayList) JsonElement(com.google.gson.JsonElement) BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity) BiConsumer(java.util.function.BiConsumer) AllBlocks(com.simibubi.create.AllBlocks) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) SelectableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup) Desktop(java.awt.Desktop) MbdComponents(com.lowdragmc.multiblocked.api.registry.MbdComponents) ItemStackTexture(com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) TrackedDummyWorld(com.lowdragmc.lowdraglib.utils.TrackedDummyWorld) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) GuiTextureGroup(com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup) BlockPos(net.minecraft.util.math.BlockPos) IGuiTexture(com.lowdragmc.lowdraglib.gui.texture.IGuiTexture) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) SceneWidget(com.lowdragmc.lowdraglib.gui.widget.SceneWidget) File(java.io.File) List(java.util.List) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) FileUtility(com.lowdragmc.lowdraglib.utils.FileUtility) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) PartWidget(com.lowdragmc.multiblocked.api.gui.blueprint_table.components.PartWidget) Collections(java.util.Collections) ItemStackTexture(com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture) CreatePartWidget(com.lowdragmc.multiblocked.common.gui.component.CreatePartWidget) PartWidget(com.lowdragmc.multiblocked.api.gui.blueprint_table.components.PartWidget) CreatePartDefinition(com.lowdragmc.multiblocked.common.definition.CreatePartDefinition) CreatePartDefinition(com.lowdragmc.multiblocked.common.definition.CreatePartDefinition) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) CreatePartWidget(com.lowdragmc.multiblocked.common.gui.component.CreatePartWidget) File(java.io.File)

Aggregations

JsonElement (com.google.gson.JsonElement)1 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)1 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)1 GuiTextureGroup (com.lowdragmc.lowdraglib.gui.texture.GuiTextureGroup)1 IGuiTexture (com.lowdragmc.lowdraglib.gui.texture.IGuiTexture)1 ItemStackTexture (com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture)1 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)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 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)1 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)1 SceneWidget (com.lowdragmc.lowdraglib.gui.widget.SceneWidget)1 SelectableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.SelectableWidgetGroup)1 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)1 BlockInfo (com.lowdragmc.lowdraglib.utils.BlockInfo)1 FileUtility (com.lowdragmc.lowdraglib.utils.FileUtility)1 TrackedDummyWorld (com.lowdragmc.lowdraglib.utils.TrackedDummyWorld)1 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)1 PartDefinition (com.lowdragmc.multiblocked.api.definition.PartDefinition)1