Search in sources :

Example 6 with PartDefinition

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

Example 7 with PartDefinition

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

the class IRendererWidget method setNewRenderer.

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

Example 8 with PartDefinition

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

the class JsonBlockPatternWidget method registerBlock.

public static void registerBlock() {
    PartDefinition definition = new PartDefinition(new ResourceLocation(Multiblocked.MODID, "symbol"), SymbolTileEntity::new);
    definition.properties.isOpaque = false;
    definition.properties.tabGroup = null;
    definition.showInJei = false;
    MbdComponents.registerComponent(definition);
    symbolBlock = (BlockComponent) MbdComponents.COMPONENT_BLOCKS_REGISTRY.get(definition.location);
}
Also used : 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