Search in sources :

Example 1 with PartDefinition

use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.

the class PartScriptWidget method loadJson.

private void loadJson(ClickData clickData) {
    if (selected != null && clickData.isRemote) {
        JsonElement jsonElement = FileUtility.loadJson(selected);
        if (jsonElement != null) {
            try {
                PartDefinition definition = Multiblocked.GSON.fromJson(jsonElement, PartDefinition.class);
                part.setDefinition(definition);
                MbdComponents.TEST_DEFINITION_REGISTRY.put(definition.location, definition);
                writeClientAction(-1, buffer -> buffer.writeUtf(definition.location.toString()));
            } catch (Exception e) {
                Multiblocked.LOGGER.error("tester: error while loading the part json {}", selected.getName(), e);
            }
            textBox.setContent(Collections.singletonList(Multiblocked.GSON_PRETTY.toJson(jsonElement)));
            tfGroup.computeMax();
        }
    }
}
Also used : JsonElement(com.google.gson.JsonElement) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) IOException(java.io.IOException)

Example 2 with PartDefinition

use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.

the class MbdCapabilities method registerAnyCapabilityBlocks.

public static void registerAnyCapabilityBlocks() {
    for (MultiblockCapability<?> capability : MbdCapabilities.CAPABILITY_REGISTRY.values()) {
        ComponentDefinition definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, capability.name + ".any"));
        definition.properties.isOpaque = false;
        definition.properties.tabGroup = null;
        definition.allowRotate = false;
        definition.showInJei = false;
        MbdComponents.registerComponent(definition);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) ComponentDefinition(com.lowdragmc.multiblocked.api.definition.ComponentDefinition)

Example 3 with PartDefinition

use of com.lowdragmc.multiblocked.api.definition.PartDefinition 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)

Example 4 with PartDefinition

use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.

the class PartBuilderWidget method setNewRenderer.

private void setNewRenderer(IMultiblockedRenderer newRenderer, String type) {
    PartDefinition definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
    definition.baseRenderer = newRenderer;
    tileEntity.setDefinition(definition);
    textTexture.updateText(type);
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) CreatePartDefinition(com.lowdragmc.multiblocked.common.definition.CreatePartDefinition) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition)

Example 5 with PartDefinition

use of com.lowdragmc.multiblocked.api.definition.PartDefinition in project Multiblocked by Low-Drag-MC.

the class TemplateBuilderWidget method getComponentDefinition.

public static ComponentDefinition getComponentDefinition(ComponentDefinition definition, Set<BlockInfo> candidates) {
    if (candidates.size() == 1) {
        definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
        definition.baseRenderer = new MBDBlockStateRenderer(candidates.toArray(new BlockInfo[0])[0]);
    } else if (!candidates.isEmpty()) {
        definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "i_renderer"));
        definition.baseRenderer = new CycleBlockStateRenderer(candidates.toArray(new BlockInfo[0]));
    }
    return definition;
}
Also used : CycleBlockStateRenderer(com.lowdragmc.multiblocked.client.renderer.impl.CycleBlockStateRenderer) MBDBlockStateRenderer(com.lowdragmc.multiblocked.client.renderer.impl.MBDBlockStateRenderer) BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) ResourceLocation(net.minecraft.util.ResourceLocation) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition)

Aggregations

PartDefinition (com.lowdragmc.multiblocked.api.definition.PartDefinition)8 ResourceLocation (net.minecraft.util.ResourceLocation)7 BlockInfo (com.lowdragmc.lowdraglib.utils.BlockInfo)3 JsonElement (com.google.gson.JsonElement)2 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)2 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)2 ResourceBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture)2 ResourceTexture (com.lowdragmc.lowdraglib.gui.texture.ResourceTexture)2 TextTexture (com.lowdragmc.lowdraglib.gui.texture.TextTexture)2 ButtonWidget (com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)2 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)2 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)2 SceneWidget (com.lowdragmc.lowdraglib.gui.widget.SceneWidget)2 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)2 TrackedDummyWorld (com.lowdragmc.lowdraglib.utils.TrackedDummyWorld)2 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)2 ComponentDefinition (com.lowdragmc.multiblocked.api.definition.ComponentDefinition)2 MbdComponents (com.lowdragmc.multiblocked.api.registry.MbdComponents)2 DummyComponentTileEntity (com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity)2 IMultiblockedRenderer (com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer)2