start of modmenu config screen
This commit is contained in:
13
build.gradle
13
build.gradle
@@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.11-SNAPSHOT'
|
||||
id 'fabric-loom' version "${loom_version}"
|
||||
id 'maven-publish'
|
||||
}
|
||||
|
||||
@@ -12,11 +12,10 @@ base {
|
||||
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
maven {
|
||||
name = "Terraformers"
|
||||
url = "https://maven.terraformersmc.com/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -26,6 +25,8 @@ dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
|
||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||
|
||||
modImplementation "com.terraformersmc:modmenu:${project.modmenu_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
@@ -5,10 +5,12 @@ org.gradle.jvmargs=-Xmx1G
|
||||
minecraft_version=1.21.10
|
||||
yarn_mappings=1.21.10+build.2
|
||||
loader_version=0.17.3
|
||||
loom_version=1.12-SNAPSHOT
|
||||
# Mod Properties
|
||||
mod_version=1.2
|
||||
mod_version=1.3
|
||||
maven_group=com.kasetoatz
|
||||
archives_base_name=fastghast
|
||||
# Dependencies
|
||||
# check this on https://modmuss50.me/fabric.html
|
||||
fabric_version=0.135.0+1.21.10
|
||||
fabric_version=0.136.0+1.21.10
|
||||
modmenu_version=16.0.0-rc.1
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.kasetoatz.fastghast;
|
||||
|
||||
import com.kasetoatz.fastghast.configscreen.ConfigScreen;
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
|
||||
import net.minecraft.entity.Leashable;
|
||||
@@ -10,7 +13,7 @@ import java.util.EnumSet;
|
||||
|
||||
import static com.kasetoatz.fastghast.config.Config.load;
|
||||
|
||||
public class Fastghast implements ModInitializer
|
||||
public class Fastghast implements ModInitializer, ModMenuApi
|
||||
{
|
||||
@Override
|
||||
public void onInitialize()
|
||||
@@ -23,4 +26,10 @@ public class Fastghast implements ModInitializer
|
||||
}
|
||||
})));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory()
|
||||
{
|
||||
return ConfigScreen::new;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ThreePartsLayoutWidget;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ConfigScreen extends Screen
|
||||
{
|
||||
private final Screen parent;
|
||||
private final ThreePartsLayoutWidget layout = new ThreePartsLayoutWidget(this);
|
||||
private OptionList body;
|
||||
|
||||
public ConfigScreen(Screen parent)
|
||||
{
|
||||
super(Text.of("TEST SCREEN"));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init()
|
||||
{
|
||||
this.layout.addHeader(this.title, this.textRenderer);
|
||||
this.body = new OptionList(this.client, this.layout.getWidth(), this.layout.getContentHeight(), this.layout.getHeaderHeight(), 25);
|
||||
this.addItems();
|
||||
this.layout.addBody(body);
|
||||
this.layout.addFooter(ButtonWidget.builder(ScreenTexts.DONE, button -> this.close()).width(200).build());
|
||||
this.layout.forEachChild(this::addDrawableChild);
|
||||
this.refreshWidgetPositions();
|
||||
}
|
||||
|
||||
private void addItems()
|
||||
{
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
ButtonWidget widget = ButtonWidget.builder(Text.of("TEST"), button -> System.out.println("button pressed")).build();
|
||||
this.body.add(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshWidgetPositions()
|
||||
{
|
||||
this.layout.refreshPositions();
|
||||
if (this.body != null)
|
||||
{
|
||||
this.body.position(this.width, this.layout);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
if (this.client != null)
|
||||
{
|
||||
this.client.setScreen(this.parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.gui.DrawContext;
|
||||
import net.minecraft.client.gui.Element;
|
||||
import net.minecraft.client.gui.Selectable;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
import net.minecraft.client.gui.widget.ElementListWidget;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Option extends ElementListWidget.Entry<Option>
|
||||
{
|
||||
private final ClickableWidget widget;
|
||||
|
||||
public Option(ClickableWidget widget)
|
||||
{
|
||||
this.widget = widget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Selectable> selectableChildren()
|
||||
{
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Element> children()
|
||||
{
|
||||
return List.of(this.widget);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(DrawContext context, int mouseX, int mouseY, boolean hovered, float deltaTicks)
|
||||
{
|
||||
this.widget.setX(this.getX());
|
||||
this.widget.setY(this.getY());
|
||||
this.widget.setWidth(this.getWidth());
|
||||
this.widget.render(context, mouseX, mouseY, deltaTicks);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.kasetoatz.fastghast.configscreen;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.*;
|
||||
|
||||
public class OptionList extends ElementListWidget<Option>
|
||||
{
|
||||
public OptionList(MinecraftClient client, int width, int height, int y, int itemHeight)
|
||||
{
|
||||
super(client, width, height, y, itemHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowWidth()
|
||||
{
|
||||
return this.width - 30;
|
||||
}
|
||||
|
||||
public void add(ClickableWidget widget)
|
||||
{
|
||||
this.addEntry(new Option(widget));
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,23 @@
|
||||
"id": "fastghast",
|
||||
"version": "${version}",
|
||||
"name": "FastGhast",
|
||||
"description": "",
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
"description": "Mod that modifies the speed of the Happy Ghast",
|
||||
"authors": ["KaseToatz"],
|
||||
"contact": {
|
||||
"email": "kasetoatz@kasetoatz.com",
|
||||
"homepage": "https://modrinth.com/mod/fastghast",
|
||||
"issues": "https://git.kasetoatz.com/KaseToatz/FastGhast/issues",
|
||||
"sources": "https://git.kasetoatz.com/KaseToatz/FastGhast"
|
||||
},
|
||||
"license": "MIT",
|
||||
"icon": "icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
],
|
||||
"modmenu": [
|
||||
"com.kasetoatz.fastghast.Fastghast"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
BIN
src/main/resources/icon.png
Normal file
BIN
src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 72 KiB |
Reference in New Issue
Block a user