Search in sources :

Example 1 with IRendererWidget

use of com.lowdragmc.multiblocked.api.gui.dialogs.IRendererWidget in project Multiblocked by Low-Drag-MC.

the class ComponentWidget method createScene.

@OnlyIn(Dist.CLIENT)
protected WidgetGroup createScene(int x, int y, String text, String tips, IMultiblockedRenderer init, Consumer<IMultiblockedRenderer> onUpdate) {
    TrackedDummyWorld world = new TrackedDummyWorld();
    world.addBlock(BlockPos.ZERO, BlockInfo.fromBlockState(MbdComponents.DummyComponentBlock.defaultBlockState()));
    DummyComponentTileEntity tileEntity = (DummyComponentTileEntity) world.getBlockEntity(BlockPos.ZERO);
    tileEntity.setDefinition(new PartDefinition(new ResourceLocation(Multiblocked.MODID, "component_widget")));
    tileEntity.getDefinition().baseRenderer = init;
    WidgetGroup widgetGroup = new WidgetGroup(x, y, 90, 90);
    widgetGroup.addWidget(new LabelWidget(0, 0, text));
    widgetGroup.addWidget(new ImageWidget(0, 12, 90, 80, new ColorBorderTexture(2, 0xff4A82F7)));
    widgetGroup.addWidget(new SceneWidget(0, 12, 90, 80, world).setRenderedCore(Collections.singleton(BlockPos.ZERO), null).setRenderSelect(false).setRenderFacing(false));
    widgetGroup.addWidget(new ButtonWidget(90 - 15, 12, 15, 15, new ResourceTexture("multiblocked:textures/gui/option.png"), (cd) -> new IRendererWidget(this, tileEntity.getRenderer(), r -> {
        tileEntity.getDefinition().baseRenderer = r;
        onUpdate.accept(r);
    })).setHoverBorderTexture(1, -1).setHoverTooltips(tips));
    return widgetGroup;
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) JsonObject(com.google.gson.JsonObject) TabButton(com.lowdragmc.lowdraglib.gui.widget.TabButton) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) CapabilityTrait(com.lowdragmc.multiblocked.api.capability.trait.CapabilityTrait) IRendererWidget(com.lowdragmc.multiblocked.api.gui.dialogs.IRendererWidget) MultiblockCapability(com.lowdragmc.multiblocked.api.capability.MultiblockCapability) ResourceBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceBorderTexture) TabContainer(com.lowdragmc.lowdraglib.gui.widget.TabContainer) Dist(net.minecraftforge.api.distmarker.Dist) BlockInfo(com.lowdragmc.lowdraglib.utils.BlockInfo) TextBoxWidget(com.lowdragmc.lowdraglib.gui.widget.TextBoxWidget) Minecraft(net.minecraft.client.Minecraft) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ComponentDefinition(com.lowdragmc.multiblocked.api.definition.ComponentDefinition) DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ResourceTextureWidget(com.lowdragmc.multiblocked.api.gui.dialogs.ResourceTextureWidget) MbdComponents(com.lowdragmc.multiblocked.api.registry.MbdComponents) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) 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) SwitchWidget(com.lowdragmc.lowdraglib.gui.widget.SwitchWidget) BlockPos(net.minecraft.util.math.BlockPos) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) SceneWidget(com.lowdragmc.lowdraglib.gui.widget.SceneWidget) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) MbdCapabilities(com.lowdragmc.multiblocked.api.registry.MbdCapabilities) Consumer(java.util.function.Consumer) ColorRectTexture(com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) IRendererWidget(com.lowdragmc.multiblocked.api.gui.dialogs.IRendererWidget) TrackedDummyWorld(com.lowdragmc.lowdraglib.utils.TrackedDummyWorld) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) PartDefinition(com.lowdragmc.multiblocked.api.definition.PartDefinition) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) ColorBorderTexture(com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture) ResourceLocation(net.minecraft.util.ResourceLocation) LabelWidget(com.lowdragmc.lowdraglib.gui.widget.LabelWidget) ImageWidget(com.lowdragmc.lowdraglib.gui.widget.ImageWidget) DummyComponentTileEntity(com.lowdragmc.multiblocked.api.tile.DummyComponentTileEntity) SceneWidget(com.lowdragmc.lowdraglib.gui.widget.SceneWidget) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

JsonObject (com.google.gson.JsonObject)1 ColorBorderTexture (com.lowdragmc.lowdraglib.gui.texture.ColorBorderTexture)1 ColorRectTexture (com.lowdragmc.lowdraglib.gui.texture.ColorRectTexture)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 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)1 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)1 ImageWidget (com.lowdragmc.lowdraglib.gui.widget.ImageWidget)1 LabelWidget (com.lowdragmc.lowdraglib.gui.widget.LabelWidget)1 SceneWidget (com.lowdragmc.lowdraglib.gui.widget.SceneWidget)1 SwitchWidget (com.lowdragmc.lowdraglib.gui.widget.SwitchWidget)1 TabButton (com.lowdragmc.lowdraglib.gui.widget.TabButton)1 TabContainer (com.lowdragmc.lowdraglib.gui.widget.TabContainer)1 TextBoxWidget (com.lowdragmc.lowdraglib.gui.widget.TextBoxWidget)1 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)1 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)1 BlockInfo (com.lowdragmc.lowdraglib.utils.BlockInfo)1 TrackedDummyWorld (com.lowdragmc.lowdraglib.utils.TrackedDummyWorld)1