Search in sources :

Example 1 with CreatePartDefinition

use of com.lowdragmc.multiblocked.common.definition.CreatePartDefinition in project Multiblocked by Low-Drag-MC.

the class CommonProxy method commonSetup.

@SubscribeEvent
public void commonSetup(FMLCommonSetupEvent e) {
    e.enqueueWork(() -> {
        for (MultiblockCapability<?> capability : MbdCapabilities.CAPABILITY_REGISTRY.values()) {
            capability.getAnyBlock().definition.baseRenderer = new CycleBlockStateRenderer(capability.getCandidates());
        }
        RecipeMap.registerRecipeFromFile(Multiblocked.GSON, new File(Multiblocked.location, "recipe_map"));
        MbdComponents.commonLastWork();
        if (Multiblocked.isCreateLoaded()) {
            MbdComponents.DEFINITION_REGISTRY.forEach((r, d) -> {
                if (d instanceof CreatePartDefinition) {
                    CreatePartDefinition definition = (CreatePartDefinition) d;
                    if (definition.isOutput) {
                        BlockStressDefaults.setDefaultCapacity(d.location, definition.stress);
                    } else {
                        BlockStressDefaults.setDefaultImpact(d.location, definition.stress);
                    }
                }
            });
        }
    });
}
Also used : CycleBlockStateRenderer(com.lowdragmc.multiblocked.client.renderer.impl.CycleBlockStateRenderer) CreatePartDefinition(com.lowdragmc.multiblocked.common.definition.CreatePartDefinition) File(java.io.File) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 2 with CreatePartDefinition

use of com.lowdragmc.multiblocked.common.definition.CreatePartDefinition 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

CreatePartDefinition (com.lowdragmc.multiblocked.common.definition.CreatePartDefinition)2 File (java.io.File)2 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