Search in sources :

Example 1 with Multiblocked

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

the class GeoComponentRenderer method createConfigurator.

@Override
public Supplier<IMultiblockedRenderer> createConfigurator(WidgetGroup parent, DraggableScrollableWidgetGroup group, IMultiblockedRenderer current) {
    TextFieldWidget tfw = new TextFieldWidget(1, 1, 150, 20, null, null);
    File path = new File(Multiblocked.location, "assets/multiblocked/geo");
    AtomicBoolean isGlobal = new AtomicBoolean(false);
    if (current instanceof GeoComponentRenderer) {
        tfw.setCurrentString(((GeoComponentRenderer) current).modelName);
        isGlobal.set(((GeoComponentRenderer) current).isGlobal);
    }
    group.addWidget(new ButtonWidget(155, 1, 20, 20, cd -> DialogWidget.showFileDialog(parent, "select a geo file", path, true, DialogWidget.suffixFilter(".geo.json"), r -> {
        if (r != null && r.isFile()) {
            tfw.setCurrentString(r.getName().replace(".geo.json", ""));
        }
    })).setButtonTexture(new ResourceTexture("multiblocked:textures/gui/darkened_slot.png"), new TextTexture("F", -1)).setHoverTooltips("multiblocked.gui.tips.file_selector"));
    group.addWidget(tfw);
    group.addWidget(createBoolSwitch(1, 25, "isGlobal", "multiblocked.gui.predicate.geo.0", isGlobal.get(), isGlobal::set));
    return () -> {
        if (tfw.getCurrentString().isEmpty()) {
            return null;
        } else {
            return new GeoComponentRenderer(tfw.getCurrentString(), isGlobal.get());
        }
    };
}
Also used : JSONUtils(net.minecraft.util.JSONUtils) AnimationBuilder(software.bernie.geckolib3.core.builder.AnimationBuilder) JsonObject(com.google.gson.JsonObject) GeoBone(software.bernie.geckolib3.geo.render.built.GeoBone) Random(java.util.Random) Direction(net.minecraft.util.Direction) Dist(net.minecraftforge.api.distmarker.Dist) Gson(com.google.gson.Gson) IBlockDisplayReader(net.minecraft.world.IBlockDisplayReader) AnimationData(software.bernie.geckolib3.core.manager.AnimationData) BlockState(net.minecraft.block.BlockState) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) PlayState(software.bernie.geckolib3.core.PlayState) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) IAnimatable(software.bernie.geckolib3.core.IAnimatable) IModelData(net.minecraftforge.client.model.data.IModelData) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) AtlasTexture(net.minecraft.client.renderer.texture.AtlasTexture) Animation(software.bernie.geckolib3.core.builder.Animation) Set(java.util.Set) AnimationFile(software.bernie.geckolib3.file.AnimationFile) Objects(java.util.Objects) IGeoRenderer(software.bernie.geckolib3.renderers.geo.IGeoRenderer) List(java.util.List) Vector3f(net.minecraft.util.math.vector.Vector3f) AnimatedGeoModel(software.bernie.geckolib3.model.AnimatedGeoModel) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) GeoModelProvider(software.bernie.geckolib3.model.provider.GeoModelProvider) RenderUtils(software.bernie.geckolib3.util.RenderUtils) OverlayTexture(net.minecraft.client.renderer.texture.OverlayTexture) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn) AnimationController(software.bernie.geckolib3.core.controller.AnimationController) ItemCameraTransforms(net.minecraft.client.renderer.model.ItemCameraTransforms) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) IRenderTypeBuffer(net.minecraft.client.renderer.IRenderTypeBuffer) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) ItemStack(net.minecraft.item.ItemStack) Minecraft(net.minecraft.client.Minecraft) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) Nonnull(javax.annotation.Nonnull) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) MatrixStack(com.mojang.blaze3d.matrix.MatrixStack) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) GeoModel(software.bernie.geckolib3.geo.render.built.GeoModel) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder) RenderType(net.minecraft.client.renderer.RenderType) BlockPos(net.minecraft.util.math.BlockPos) AnimationFactory(software.bernie.geckolib3.core.manager.AnimationFactory) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) IComponent(com.lowdragmc.multiblocked.api.tile.IComponent) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) GeoCube(software.bernie.geckolib3.geo.render.built.GeoCube) ResourceLocation(net.minecraft.util.ResourceLocation) IAnimatableModel(software.bernie.geckolib3.core.IAnimatableModel) GeckoLibCache(software.bernie.geckolib3.resource.GeckoLibCache) AnimationEvent(software.bernie.geckolib3.core.event.predicate.AnimationEvent) TileEntity(net.minecraft.tileentity.TileEntity) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) Collections(java.util.Collections) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) AnimationFile(software.bernie.geckolib3.file.AnimationFile) File(java.io.File) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Example 2 with Multiblocked

use of com.lowdragmc.multiblocked.Multiblocked 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()));
        }
    };
}
Also used : JsonObject(com.google.gson.JsonObject) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) DraggableScrollableWidgetGroup(com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup) IModelRenderer(com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer) Supplier(java.util.function.Supplier) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget) File(java.io.File) DialogWidget(com.lowdragmc.lowdraglib.gui.widget.DialogWidget) Gson(com.google.gson.Gson) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) Multiblocked(com.lowdragmc.multiblocked.Multiblocked) WidgetGroup(com.lowdragmc.lowdraglib.gui.widget.WidgetGroup) IMultiblockedRenderer(com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) ResourceTexture(com.lowdragmc.lowdraglib.gui.texture.ResourceTexture) ResourceLocation(net.minecraft.util.ResourceLocation) TextTexture(com.lowdragmc.lowdraglib.gui.texture.TextTexture) TextFieldWidget(com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget) IModelRenderer(com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer) File(java.io.File) ButtonWidget(com.lowdragmc.lowdraglib.gui.widget.ButtonWidget)

Aggregations

Gson (com.google.gson.Gson)2 JsonObject (com.google.gson.JsonObject)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 DialogWidget (com.lowdragmc.lowdraglib.gui.widget.DialogWidget)2 DraggableScrollableWidgetGroup (com.lowdragmc.lowdraglib.gui.widget.DraggableScrollableWidgetGroup)2 TextFieldWidget (com.lowdragmc.lowdraglib.gui.widget.TextFieldWidget)2 WidgetGroup (com.lowdragmc.lowdraglib.gui.widget.WidgetGroup)2 Multiblocked (com.lowdragmc.multiblocked.Multiblocked)2 IMultiblockedRenderer (com.lowdragmc.multiblocked.client.renderer.IMultiblockedRenderer)2 File (java.io.File)2 Supplier (java.util.function.Supplier)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 IModelRenderer (com.lowdragmc.lowdraglib.client.renderer.impl.IModelRenderer)1 IComponent (com.lowdragmc.multiblocked.api.tile.IComponent)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1