use of com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer in project Multiblocked by Low-Drag-MC.
the class ComponentTileEntity method getRenderer.
public IMultiblockedRenderer getRenderer() {
IMultiblockedRenderer lastRenderer = currentRenderer;
currentRenderer = updateCurrentRenderer();
if (lastRenderer != currentRenderer) {
if (lastRenderer != null) {
lastRenderer.onPostAccess(this);
}
if (currentRenderer != null) {
currentRenderer.onPreAccess(this);
}
}
return currentRenderer;
}
use of com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer in project Multiblocked by Low-Drag-MC.
the class MBDIModelRenderer method createConfigurator.
@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
TextFieldWidget tfw = new TextFieldWidget(1, 1, 150, 20, null, null);
group.addWidget(tfw);
File path = new File(Multiblocked.location, "assets/multiblocked/models");
group.addWidget(new ButtonWidget(155, 1, 20, 20, cd -> DialogWidget.showFileDialog(parent, "select a java model", path, true, DialogWidget.suffixFilter(".json"), r -> {
if (r != null && r.isFile()) {
tfw.setCurrentString("multiblocked:" + r.getPath().replace(path.getPath(), "").substring(1).replace(".json", "").replace('\\', '/'));
}
})).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/darkened_slot.png"), new TextTexture("F", -1)).setHoverTooltips("multiblocked.gui.tips.file_selector"));
if (current instanceof IModelRenderer && ((IModelRenderer) current).modelLocation != null) {
tfw.setCurrentString(((IModelRenderer) current).modelLocation.toString());
}
return () -> {
if (tfw.getCurrentString().isEmpty()) {
return null;
} else {
return new MBDIModelRenderer(new ResourceLocation(tfw.getCurrentString()));
}
};
}
use of com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer 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;
}
use of com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer in project Multiblocked by Low-Drag-MC.
the class IRendererWidget method onChangeRenderer.
private void onChangeRenderer(String s) {
group.clearAllWidgets();
onUpdate = null;
IMultiblockedRenderer current = tileEntity.getRenderer();
String[] split = s.split("\\.");
s = split[split.length - 1];
if (s.equals("null")) {
onUpdate = () -> setNewRenderer(null);
} else {
IMultiblockedRenderer renderer = MbdRenderers.getRenderer(s);
if (renderer != null) {
Supplier<IMultiblockedRenderer> supplier = renderer.createConfigurator(this, group, current);
if (supplier != null) {
onUpdate = () -> setNewRenderer(supplier.get());
}
}
}
}
Aggregations