Update for mc1.21.1

This commit is contained in:
2025-04-30 20:44:45 +02:00
parent 6c2f7a47e2
commit d4ec55c0fa
45 changed files with 537 additions and 1081 deletions

165
LICENSE Normal file
View File

@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.

View File

@@ -1,4 +1,5 @@
# Mechanical Lemon UI
# Mechanical UI
> I love Create and its many utility and classes. I can't live without.
- This library mod is a stripped version of Create ui foundation which is licensed under the MIT license. See Create's license for more information.
- All the credits go to the Creators of Create team.
- https://github.com/Creators-of-Create/Create

View File

@@ -1,193 +1,182 @@
plugins {
id 'eclipse'
id 'idea'
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
id 'maven-publish'
id "idea"
id "net.neoforged.moddev" version "2.0.74"
id "dev.ithundxr.silk" version "0.11.15"
id "me.modmuss50.mod-publish-plugin" version "0.8.3"
id "maven-publish"
}
apply from: "./gradle/java.gradle"
apply from: "gradle/property_loader.gradle"
group = "com.${author}.${modid}"
group = "com.${mod_author}.${mod_id}"
version = "${minecraft_version}-${mod_version}"
archivesBaseName = modid
archivesBaseName = mod_id
java {
toolchain.languageVersion = JavaLanguageVersion.of(17)
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// official MCVersion Official field/method names from Mojang mapping files
// parchment YYYY.MM.DD-MCVersion Open community-sourced parameter names and javadocs layered on top of official
//
// You must be aware of the Mojang license when using the 'official' or 'parchment' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Parchment is an unofficial project maintained by ParchmentMC, separate from MinecraftForge
// Additional setup is needed to use their mappings: https://parchmentmc.org/docs/getting-started
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: mapping_channel, version: mapping_version
neoForge {
version = project.neo_version
// When true, this property will have all Eclipse/IntelliJ IDEA run configurations run the "prepareX" task for the given run configuration before launching the game.
// In most cases, it is not necessary to enable.
// enableEclipsePrepareRuns = true
// enableIdeaPrepareRuns = true
accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
// This property allows configuring Gradle's ProcessResources task(s) to run on IDE output locations before launching the game.
// It is REQUIRED to be set to true for this template to function.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
copyIdeResources = true
// When true, this property will add the folder name of all declared run configurations to generated IDE run configurations.
// The folder name can be set on a run configuration using the "folderName" property.
// By default, the folder name of a run configuration is the name of the Gradle project containing it.
// generateRunFolders = true
// This property enables access transformers for use in development.
// They will be applied to the Minecraft artifact.
// The access transformer file can be anywhere in the project.
// However, it must be at "META-INF/accesstransformer.cfg" in the final mod jar to be loaded by Forge.
// This default location is a best practice to automatically put the file in the right place in the final jar.
// See https://docs.minecraftforge.net/en/latest/advanced/accesstransformers/ for more information.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
parchment {
minecraftVersion = project.parchment_minecraft_version
mappingsVersion = project.parchment_version
}
mods {
"$mod_id" {
sourceSet sourceSets.main
}
}
runs {
// applies to all the run configs below
configureEach {
workingDirectory project.file('run')
systemProperty 'forge.logging.markers', ''
systemProperty 'forge.logging.console.level', 'info'
jvmArguments = ["-XX:+IgnoreUnrecognizedVMOptions", "-XX:+AllowEnhancedClassRedefinition"]
//jvmArgs("-XX:-OmitStackTraceInFastThrow") // uncomment when you get exceptions with null messages etc
//jvmArgs '-XX:+UnlockCommercialFeatures' // uncomment for profiling
// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
property 'forge.logging.markers', 'REGISTRIES'
systemProperty 'mixin.debug.export', 'true'
systemProperty 'mixin.debug.verbose', 'true'
programArgument '-mixin.config=create.mixins.json'
//programArgument '-mixin.config=ponder.mixins.json'
//systemProperty("mixin.env.remapRefMap", "true")
//systemProperty("mixin.env.refMapRemappingFile", "${projectDir}/build/createSrgToMcp/output.srg")
// Recommended logging level for the console
// You can set various levels here.
// Please read: https://stackoverflow.com/questions/2031163/when-to-use-the-different-log-levels
property 'forge.logging.console.level', 'debug'
mods {
"${modid}" {
source sourceSets.main
}
}
}
client {
// Comma-separated list of namespaces to load gametests from. Empty = all namespaces.
property 'forge.enabledGameTestNamespaces', modid
client()
gameDirectory = project.file('run')
}
server {
property 'forge.enabledGameTestNamespaces', modid
args '--nogui'
}
server()
// This run config launches GameTestServer and runs all registered gametests, then exits.
// By default, the server will crash when no gametests are provided.
// The gametest system is also enabled by default for other run configs under the /test command.
gameTestServer {
property 'forge.enabledGameTestNamespaces', modid
gameDirectory = project.file('run/server')
}
data {
// example of overriding the workingDirectory set in configureEach above
workingDirectory project.file('run-data')
data()
// Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources.
args '--mod', modid, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
gameDirectory = project.file('run')
systemProperty 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP'
systemProperty 'forge.logging.console.level', 'debug'
programArguments.addAll("--mod", mod_id as String, "--all", "--output", file("src/generated/resources/").getAbsolutePath(), "--existing", file("src/main/resources").getAbsolutePath())
}
gameTestServer {
type = "gameTestServer"
gameDirectory = project.file('run/gametest')
// setForceExit false <- FIXME 1.20
}
}
}
// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }
sourceSets.main {
resources {
srcDir 'src/generated/resources'
exclude '.cache/'
}
}
repositories {
maven {
// location of the maven for Registrate and Flywheel
name = 'tterrag maven'
url = 'https://maven.tterrag.com'
}
maven {
// location of the maven that hosts JEI files since January 2023
// location of the maven for Vazkii's mods
name = "Jared's maven"
url = "https://maven.blamejared.com/"
}
maven { url = "https://maven.createmod.net" } // Create, Ponder, Flywheel
maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // ForgeConfigAPIPort
maven { url = "https://mvn.devos.one/snapshots" } // Registrate
maven { url = "https://maven.blamejared.com" } // JEI, Vazkii's Mods
maven {
// location of the maven for Curios API
url = "https://maven.theillusivec4.top/"
}
maven {
// location of maven for CC: Tweaked
name = "squiddev"
url = "https://squiddev.cc/maven/"
}
maven {
url = 'https://www.cursemaven.com'
content {
includeGroup "curse.maven"
}
}
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
content {
includeGroup "maven.modrinth"
}
}
maven {
url "https://jitpack.io"
content {
includeGroup "com.github.llamalad7.mixinextras"
}
}
maven {
url "https://maven.latvian.dev/releases"
content {
includeGroup "dev.latvian.mods"
includeGroup "dev.latvian.apps"
}
}
maven {
url "https://maven.architectury.dev/"
content {
includeGroup "dev.architectury"
}
}
mavenLocal()
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'org.jetbrains:annotations:22.0.0'
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
implementation("net.createmod.ponder:Ponder-NeoForge-${minecraft_version}:${ponder_version}")
compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}")
/*compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${jei_minecraft_version}-forge:${jei_version}")
*/
/*implementation fg.deobf("curse.maven:jade-324717:${jade_id}")*/
implementation fg.deobf("curse.maven:jade-324717:${jade_id}")
}
if (System.getProperty('idea.sync.active') != 'true') {
annotationProcessor "org.spongepowered:mixin:${mixin_version}:processor"
processResources {
def buildProps = project.properties.clone()
// Replaces FML's magic file.jarVersion string with the correct version at build time.
buildProps.put('file', [jarVersion: project.version])
filesMatching(['META-INF/neoforge.mods.toml', 'pack.mcmeta']) {
expand buildProps
}
}
// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
// When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments.
// See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html
tasks.named('processResources', ProcessResources).configure {
var replaceProperties = [minecraft_version : minecraft_version, minecraft_version_range: minecraft_version_range,
forge_version : forge_version, forge_version_range: forge_version_range,
loader_version_range: loader_version_range,
modid : modid, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version,
author : author, mod_description: mod_description,]
inputs.properties replaceProperties
filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) {
expand replaceProperties + [project: project]
}
compileJava {
options.compilerArgs = ['-Xdiags:verbose']
}
// Example for how to get properties into the manifest for reading at runtime.
tasks.named('jar', Jar).configure {
manifest {
attributes(["Specification-Title" : modid,
"Specification-Vendor" : author,
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : project.jar.archiveVersion,
"Implementation-Vendor" : author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")])
jar {
from('LICENSE') {
rename { "${it}_${archivesBaseName}" }
}
// This is the preferred method to reobfuscate your jar file
finalizedBy 'reobfJar'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}
publishing {
// other settings of publication
publications {

View File

@@ -1,28 +1,21 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false
minecraft_version=1.20.1
minecraft_version_range=[1.20.1,1.21)
forge_version=47.3.7
forge_version_range=[47,)
loader_version_range=[47,)
mapping_channel=official
mapping_version=1.20.1
mixin_version = 0.8.5
minecraft_version = 1.21.1
minecraft_version_range=[1.21.1]
neo_version = 21.1.125
neo_version_range=[21.1.125,)
modid=mechanical_lemon_ui
mod_name=Mechanical Lemon UI
mod_license=MIT
mod_version=0.1.8
parchment_minecraft_version = 1.21.1
parchment_version = 2024.11.17
mod_id=mechanicals_ui
mod_name=Mechanicals UI
mod_license=LGPL3
mod_version=0.0.2
mod_group_id=com.oierbravo
author=oierbravo
mod_description=Library
mod_author=oierbravo
mod_description=Ui Library
jei_minecraft_version = 1.20.1
jei_version = 15.2.0.22
curios_minecraft_version = 1.20.1
curios_version = 5.2.0-beta.3
jade_id = 5672013
ponder_version = 1.0.46

39
gradle/java.gradle Normal file
View File

@@ -0,0 +1,39 @@
apply plugin: 'java'
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
java.withSourcesJar()
java.withJavadocJar()
jar {
manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version' : project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
'Timestampe' : System.currentTimeMillis(),
'Built-On-Java' : "${System.getProperty('java.vm.version')} (${System.getProperty('java.vm.vendor')})",
'Built-On-Minecraft' : minecraft_version
])
}
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = 'UTF-8'
it.options.release = 21
}
// Disables Gradle's custom module metadata from being published to maven. The
// metadata includes mapped dependencies which are not reasonably consumable by
// other mod developers.
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
javadoc {
// Suppress annoying warnings when generating JavaDoc files.
options.addStringOption('Xdoclint:none', '-quiet')
}

View File

@@ -0,0 +1,48 @@
/*
This module can inject build properties from a JSON file. Each property in the
JSON file will be mapped to a build property using the key of that property.
Property keys ending with _comment will be skipped.
If a secretFile property exists and points to a valid JSON file that file will
be automatically loaded. You can manually load a file using the loadProperties
method.
*/
import groovy.json.JsonSlurper
// Auto detects a secret file and injects it.
if (project.rootProject.hasProperty("secretFile")) {
project.logger.lifecycle("Automatically loading properties from the secretFile")
final def secretsFile = project.rootProject.file(project.rootProject.getProperty("secretFile"))
if (secretsFile.exists() && secretsFile.name.endsWith(".json")) {
loadProperties(secretsFile)
}
}
// Loads properties using a specified json file.
def loadProperties(propertyFile) {
if (propertyFile.exists()) {
propertyFile.withReader {
Map propMap = new JsonSlurper().parse it
for (entry in propMap) {
// Filter entries that use _comment in the key.
if (!entry.key.endsWith("_comment")) {
project.ext.set(entry.key, entry.value)
}
}
project.logger.lifecycle("Successfully loaded " + propMap.size() + " properties")
propMap.clear()
}
} else {
project.logger.warn("The property file " + propertyFile.getName() + " could not be loaded. It does not exist.")
}
}
// Allows other scripts to use these methods.
ext {
loadProperties = this.&loadProperties
}

View File

@@ -12,4 +12,4 @@ plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}
rootProject.name = 'MechanicalLemonUI'
rootProject.name = 'MechanicalsUI'

View File

@@ -1,31 +0,0 @@
package com.oierbravo.mechanical_lemon_ui;
import com.mojang.logging.LogUtils;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.slf4j.Logger;
// The value here should match an entry in the META-INF/mods.toml file
@Mod(MechanicalLemonUI.MODID)
public class MechanicalLemonUI {
public static final String MODID = "mechanical_lemon_ui";
private static final Logger LOGGER = LogUtils.getLogger();
public MechanicalLemonUI() {
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
MinecraftForge.EVENT_BUS.register(this);
}
public static ResourceLocation asResource(String path) {
return new ResourceLocation(MODID, path);
}
}

View File

@@ -1,101 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.Color;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.GameRenderer;
import org.joml.Matrix4f;
public class UIRenderHelper {
public static CustomRenderTarget framebuffer;
public UIRenderHelper() {
}
public static void init() {
RenderSystem.recordRenderCall(() -> {
Window mainWindow = Minecraft.getInstance().getWindow();
framebuffer = UIRenderHelper.CustomRenderTarget.create(mainWindow);
});
}
public static void updateWindowSize(Window mainWindow) {
if (framebuffer != null) {
framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX);
}
}
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int tex_left, int tex_top, int width, int height) {
drawColoredTexture(graphics, c, x, y, 0, (float) tex_left, (float) tex_top, width, height, 256, 256);
}
public static void drawColoredTexture(GuiGraphics graphics, Color c, int x, int y, int z, float tex_left, float tex_top, int width, int height, int sheet_width, int sheet_height) {
drawColoredTexture(graphics, c, x, x + width, y, y + height, z, width, height, tex_left, tex_top, sheet_width, sheet_height);
}
private static void drawColoredTexture(GuiGraphics graphics, Color c, int left, int right, int top, int bot, int z, int tex_width, int tex_height, float tex_left, float tex_top, int sheet_width, int sheet_height) {
drawTexturedQuad(graphics.pose().last().pose(), c, left, right, top, bot, z, (tex_left + 0.0F) / (float)sheet_width, (tex_left + (float)tex_width) / (float)sheet_width, (tex_top + 0.0F) / (float)sheet_height, (tex_top + (float)tex_height) / (float)sheet_height);
}
private static void drawTexturedQuad(Matrix4f m, Color c, int left, int right, int top, int bot, int z, float u1, float u2, float v1, float v2) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tesselator.getBuilder();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.setShader(GameRenderer::getPositionColorTexShader);
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
bufferbuilder.vertex(m, (float)left, (float)bot, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v2).endVertex();
bufferbuilder.vertex(m, (float)right, (float)bot, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v2).endVertex();
bufferbuilder.vertex(m, (float)right, (float)top, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u2, v1).endVertex();
bufferbuilder.vertex(m, (float)left, (float)top, (float)z).color(c.getRed(), c.getGreen(), c.getBlue(), c.getAlpha()).uv(u1, v1).endVertex();
tesselator.end();
RenderSystem.disableBlend();
}
public static class CustomRenderTarget extends RenderTarget {
public CustomRenderTarget(boolean useDepth) {
super(useDepth);
}
public static CustomRenderTarget create(Window mainWindow) {
CustomRenderTarget framebuffer = new CustomRenderTarget(true);
framebuffer.resize(mainWindow.getWidth(), mainWindow.getHeight(), Minecraft.ON_OSX);
framebuffer.setClearColor(0.0F, 0.0F, 0.0F, 0.0F);
framebuffer.enableStencil();
return framebuffer;
}
public void renderWithAlpha(float alpha) {
Window window = Minecraft.getInstance().getWindow();
float vx = (float)window.getGuiScaledWidth();
float vy = (float)window.getGuiScaledHeight();
float tx = (float)this.viewWidth / (float)this.width;
float ty = (float)this.viewHeight / (float)this.height;
RenderSystem.enableDepthTest();
RenderSystem.setShader(() -> {
return Minecraft.getInstance().gameRenderer.blitShader;
});
RenderSystem.getShader().setSampler("DiffuseSampler", this.colorTextureId);
this.bindRead();
Tesselator tessellator = Tesselator.getInstance();
BufferBuilder bufferbuilder = tessellator.getBuilder();
bufferbuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_COLOR_TEX);
bufferbuilder.vertex(0.0, (double)vy, 0.0).color(1.0F, 1.0F, 1.0F, alpha).uv(0.0F, 0.0F).endVertex();
bufferbuilder.vertex((double)vx, (double)vy, 0.0).color(1.0F, 1.0F, 1.0F, alpha).uv(tx, 0.0F).endVertex();
bufferbuilder.vertex((double)vx, 0.0, 0.0).color(1.0F, 1.0F, 1.0F, alpha).uv(tx, ty).endVertex();
bufferbuilder.vertex(0.0, 0.0, 0.0).color(1.0F, 1.0F, 1.0F, alpha).uv(0.0F, ty).endVertex();
tessellator.end();
this.unbindRead();
}
}
}

View File

@@ -1,243 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.google.common.hash.Hashing;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.Vec3;
import org.joml.Vector3f;
import javax.annotation.Nonnull;
import java.util.function.UnaryOperator;
public class Color {
public static final Color TRANSPARENT_BLACK = (new Color(0, 0, 0, 0)).setImmutable();
public static final Color BLACK = (new Color(0, 0, 0)).setImmutable();
public static final Color WHITE = (new Color(255, 255, 255)).setImmutable();
public static final Color RED = (new Color(255, 0, 0)).setImmutable();
public static final Color GREEN = (new Color(0, 255, 0)).setImmutable();
public static final Color SPRING_GREEN = (new Color(0, 255, 187)).setImmutable();
protected boolean mutable;
protected int value;
public Color(int r, int g, int b) {
this(r, g, b, 255);
}
public Color(int r, int g, int b, int a) {
this.mutable = true;
this.value = (a & 255) << 24 | (r & 255) << 16 | (g & 255) << 8 | (b & 255) << 0;
}
public Color(float r, float g, float b, float a) {
this((int)(0.5 + (double)(255.0F * Mth.clamp(r, 0.0F, 1.0F))), (int)(0.5 + (double)(255.0F * Mth.clamp(g, 0.0F, 1.0F))), (int)(0.5 + (double)(255.0F * Mth.clamp(b, 0.0F, 1.0F))), (int)(0.5 + (double)(255.0F * Mth.clamp(a, 0.0F, 1.0F))));
}
public Color(int rgba) {
this.mutable = true;
this.value = rgba;
}
public Color(int rgb, boolean hasAlpha) {
this.mutable = true;
if (hasAlpha) {
this.value = rgb;
} else {
this.value = rgb | -16777216;
}
}
public Color copy() {
return this.copy(true);
}
public Color copy(boolean mutable) {
return mutable ? new Color(this.value) : (new Color(this.value)).setImmutable();
}
public Color setImmutable() {
this.mutable = false;
return this;
}
public int getRed() {
return this.getRGB() >> 16 & 255;
}
public int getGreen() {
return this.getRGB() >> 8 & 255;
}
public int getBlue() {
return this.getRGB() >> 0 & 255;
}
public int getAlpha() {
return this.getRGB() >> 24 & 255;
}
public float getRedAsFloat() {
return (float)this.getRed() / 255.0F;
}
public float getGreenAsFloat() {
return (float)this.getGreen() / 255.0F;
}
public float getBlueAsFloat() {
return (float)this.getBlue() / 255.0F;
}
public float getAlphaAsFloat() {
return (float)this.getAlpha() / 255.0F;
}
public int getRGB() {
return this.value;
}
public Vec3 asVector() {
return new Vec3((double)this.getRedAsFloat(), (double)this.getGreenAsFloat(), (double)this.getBlueAsFloat());
}
public Vector3f asVectorF() {
return new Vector3f(this.getRedAsFloat(), this.getGreenAsFloat(), this.getBlueAsFloat());
}
public Color setRed(int r) {
return this.ensureMutable().setRedUnchecked(r);
}
public Color setGreen(int g) {
return this.ensureMutable().setGreenUnchecked(g);
}
public Color setBlue(int b) {
return this.ensureMutable().setBlueUnchecked(b);
}
public Color setAlpha(int a) {
return this.ensureMutable().setAlphaUnchecked(a);
}
public Color setRed(float r) {
return this.ensureMutable().setRedUnchecked((int)(255.0F * Mth.clamp(r, 0.0F, 1.0F)));
}
public Color setGreen(float g) {
return this.ensureMutable().setGreenUnchecked((int)(255.0F * Mth.clamp(g, 0.0F, 1.0F)));
}
public Color setBlue(float b) {
return this.ensureMutable().setBlueUnchecked((int)(255.0F * Mth.clamp(b, 0.0F, 1.0F)));
}
public Color setAlpha(float a) {
return this.ensureMutable().setAlphaUnchecked((int)(255.0F * Mth.clamp(a, 0.0F, 1.0F)));
}
public Color scaleAlpha(float factor) {
return this.ensureMutable().setAlphaUnchecked((int)((float)this.getAlpha() * Mth.clamp(factor, 0.0F, 1.0F)));
}
public Color mixWith(Color other, float weight) {
return this.ensureMutable().setRedUnchecked((int)((float)this.getRed() + (float)(other.getRed() - this.getRed()) * weight)).setGreenUnchecked((int)((float)this.getGreen() + (float)(other.getGreen() - this.getGreen()) * weight)).setBlueUnchecked((int)((float)this.getBlue() + (float)(other.getBlue() - this.getBlue()) * weight)).setAlphaUnchecked((int)((float)this.getAlpha() + (float)(other.getAlpha() - this.getAlpha()) * weight));
}
public Color darker() {
int a = this.getAlpha();
return this.ensureMutable().mixWith(BLACK, 0.25F).setAlphaUnchecked(a);
}
public Color brighter() {
int a = this.getAlpha();
return this.ensureMutable().mixWith(WHITE, 0.25F).setAlphaUnchecked(a);
}
public Color setValue(int value) {
return this.ensureMutable().setValueUnchecked(value);
}
public Color modifyValue(UnaryOperator<Integer> function) {
int newValue = (Integer)function.apply(this.value);
return newValue == this.value ? this : this.ensureMutable().setValueUnchecked(newValue);
}
protected Color ensureMutable() {
return this.mutable ? this : new Color(this.value);
}
protected Color setRedUnchecked(int r) {
this.value = this.value & -16711681 | (r & 255) << 16;
return this;
}
protected Color setGreenUnchecked(int g) {
this.value = this.value & -65281 | (g & 255) << 8;
return this;
}
protected Color setBlueUnchecked(int b) {
this.value = this.value & -256 | (b & 255) << 0;
return this;
}
protected Color setAlphaUnchecked(int a) {
this.value = this.value & 16777215 | (a & 255) << 24;
return this;
}
protected Color setValueUnchecked(int value) {
this.value = value;
return this;
}
public static Color mixColors(@Nonnull Color c1, @Nonnull Color c2, float w) {
return new Color((int)((float)c1.getRed() + (float)(c2.getRed() - c1.getRed()) * w), (int)((float)c1.getGreen() + (float)(c2.getGreen() - c1.getGreen()) * w), (int)((float)c1.getBlue() + (float)(c2.getBlue() - c1.getBlue()) * w), (int)((float)c1.getAlpha() + (float)(c2.getAlpha() - c1.getAlpha()) * w));
}
public static Color mixColors(@Nonnull Couple<Color> colors, float w) {
return mixColors((Color)colors.getFirst(), (Color)colors.getSecond(), w);
}
public static int mixColors(int color1, int color2, float w) {
int a1 = color1 >> 24;
int r1 = color1 >> 16 & 255;
int g1 = color1 >> 8 & 255;
int b1 = color1 & 255;
int a2 = color2 >> 24;
int r2 = color2 >> 16 & 255;
int g2 = color2 >> 8 & 255;
int b2 = color2 & 255;
return ((int)((float)a1 + (float)(a2 - a1) * w) << 24) + ((int)((float)r1 + (float)(r2 - r1) * w) << 16) + ((int)((float)g1 + (float)(g2 - g1) * w) << 8) + ((int)((float)b1 + (float)(b2 - b1) * w) << 0);
}
public static Color rainbowColor(int timeStep) {
int localTimeStep = Math.abs(timeStep) % 1536;
int timeStepInPhase = localTimeStep % 256;
int phaseBlue = localTimeStep / 256;
int red = colorInPhase(phaseBlue + 4, timeStepInPhase);
int green = colorInPhase(phaseBlue + 2, timeStepInPhase);
int blue = colorInPhase(phaseBlue, timeStepInPhase);
return new Color(red, green, blue);
}
private static int colorInPhase(int phase, int progress) {
phase %= 6;
if (phase <= 1) {
return 0;
} else if (phase == 2) {
return progress;
} else {
return phase <= 4 ? 255 : 255 - progress;
}
}
public static Color generateFromLong(long l) {
return rainbowColor(Hashing.crc32().hashLong(l).asInt()).mixWith(WHITE, 0.5F);
}
}

View File

@@ -1,89 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class Lang {
public Lang() {
}
public static MutableComponent translateDirect(String key, Object... args) {
return Components.translatable("create." + key, resolveBuilders(args));
}
public static String asId(String name) {
return name.toLowerCase(Locale.ROOT);
}
public static String nonPluralId(String name) {
String asId = asId(name);
return asId.endsWith("s") ? asId.substring(0, asId.length() - 1) : asId;
}
public static List<Component> translatedOptions(String prefix, String... keys) {
List<Component> result = new ArrayList(keys.length);
String[] var3 = keys;
int var4 = keys.length;
for(int var5 = 0; var5 < var4; ++var5) {
String key = var3[var5];
result.add(translate((prefix != null ? prefix + "." : "") + key).component());
}
return result;
}
public static LangBuilder builder() {
return new LangBuilder("create");
}
public static LangBuilder builder(String namespace) {
return new LangBuilder(namespace);
}
public static LangBuilder blockName(BlockState state) {
return builder().add(state.getBlock().getName());
}
public static LangBuilder itemName(ItemStack stack) {
return builder().add(stack.getHoverName().copy());
}
public static LangBuilder fluidName(FluidStack stack) {
return builder().add(stack.getDisplayName().copy());
}
public static LangBuilder number(double d) {
return builder().text(LangNumberFormat.format(d));
}
public static LangBuilder translate(String langKey, Object... args) {
return builder().translate(langKey, args);
}
public static LangBuilder text(String text) {
return builder().text(text);
}
public static Object[] resolveBuilders(Object[] args) {
for(int i = 0; i < args.length; ++i) {
Object var3 = args[i];
if (var3 instanceof LangBuilder cb) {
args[i] = cb.component();
}
}
return args;
}
}

View File

@@ -1,194 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import joptsimple.internal.Strings;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import java.util.List;
public class LangBuilder {
String namespace;
MutableComponent component;
public LangBuilder(String namespace) {
this.namespace = namespace;
}
public LangBuilder space() {
return text(" ");
}
public LangBuilder newLine() {
return text("\n");
}
/**
* Appends a localised component<br>
* To add an independently formatted localised component, use add() and a nested
* builder
*
* @param langKey
* @param args
* @return
*/
public LangBuilder translate(String langKey, Object... args) {
return add(Components.translatable(namespace + "." + langKey, Lang.resolveBuilders(args)));
}
/**
* Appends a text component
*
* @param literalText
* @return
*/
public LangBuilder text(String literalText) {
return add(Components.literal(literalText));
}
/**
* Appends a colored text component
*
* @param format
* @param literalText
* @return
*/
public LangBuilder text(ChatFormatting format, String literalText) {
return add(Components.literal(literalText).withStyle(format));
}
/**
* Appends a colored text component
*
* @param color
* @param literalText
* @return
*/
public LangBuilder text(int color, String literalText) {
return add(Components.literal(literalText).withStyle(s -> s.withColor(color)));
}
/**
* Appends the contents of another builder
*
* @param otherBuilder
* @return
*/
public LangBuilder add(LangBuilder otherBuilder) {
return add(otherBuilder.component());
}
/**
* Appends a component
*
* @param customComponent
* @return
*/
public LangBuilder add(MutableComponent customComponent) {
component = component == null ? customComponent : component.append(customComponent);
return this;
}
/**
* Appends a component
*
* @param component the component to append
* @return this builder
*/
public LangBuilder add(Component component) {
if (component instanceof MutableComponent mutableComponent)
return add(mutableComponent);
else
return add(component.copy());
}
//
/**
* Applies the format to all added components
*
* @param format
* @return
*/
public LangBuilder style(ChatFormatting format) {
assertComponent();
component = component.withStyle(format);
return this;
}
/**
* Applies the color to all added components
*
* @param color
* @return
*/
public LangBuilder color(int color) {
assertComponent();
component = component.withStyle(s -> s.withColor(color));
return this;
}
//
public MutableComponent component() {
assertComponent();
return component;
}
public String string() {
return component().getString();
}
public String json() {
return Component.Serializer.toJson(component());
}
public void sendStatus(Player player) {
player.displayClientMessage(component(), true);
}
public void sendChat(Player player) {
player.displayClientMessage(component(), false);
}
public void addTo(List<? super MutableComponent> tooltip) {
tooltip.add(component());
}
public void forGoggles(List<? super MutableComponent> tooltip) {
forGoggles(tooltip, 0);
}
public void forGoggles(List<? super MutableComponent> tooltip, int indents) {
tooltip.add(Lang.builder()
.text(Strings.repeat(' ', getIndents(Minecraft.getInstance().font, 4 + indents)))
.add(this)
.component());
}
public static final float DEFAULT_SPACE_WIDTH = 4.0F; // space width in vanilla's default font
static int getIndents(Font font, int defaultIndents) {
int spaceWidth = font.width(" ");
if (DEFAULT_SPACE_WIDTH == spaceWidth) {
return defaultIndents;
}
return Mth.ceil(DEFAULT_SPACE_WIDTH * defaultIndents / spaceWidth);
}
//
private void assertComponent() {
if (component == null)
throw new IllegalStateException("No components were added to builder");
}
}

View File

@@ -1,14 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import net.minecraft.client.gui.GuiGraphics;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public interface ScreenElement {
@OnlyIn(Dist.CLIENT)
void render(GuiGraphics var1, int var2, int var3);
}

View File

@@ -1,146 +0,0 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.apache.commons.lang3.mutable.MutableObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
public class VoxelShaper {
private Map<Direction, VoxelShape> shapes = new HashMap<>();
public VoxelShape get(Direction direction) {
return shapes.get(direction);
}
public VoxelShape get(Axis axis) {
return shapes.get(axisAsFace(axis));
}
public static VoxelShaper forHorizontal(VoxelShape shape, Direction facing) {
return forDirectionsWithRotation(shape, facing, Direction.Plane.HORIZONTAL, new HorizontalRotationValues());
}
public static VoxelShaper forHorizontalAxis(VoxelShape shape, Axis along) {
return forDirectionsWithRotation(shape, axisAsFace(along), Arrays.asList(Direction.SOUTH, Direction.EAST),
new HorizontalRotationValues());
}
public static VoxelShaper forDirectional(VoxelShape shape, Direction facing) {
return forDirectionsWithRotation(shape, facing, Arrays.asList(Iterate.directions), new DefaultRotationValues());
}
public static VoxelShaper forAxis(VoxelShape shape, Axis along) {
return forDirectionsWithRotation(shape, axisAsFace(along),
Arrays.asList(Direction.SOUTH, Direction.EAST, Direction.UP), new DefaultRotationValues());
}
public VoxelShaper withVerticalShapes(VoxelShape upShape) {
shapes.put(Direction.UP, upShape);
shapes.put(Direction.DOWN, rotatedCopy(upShape, new Vec3(180, 0, 0)));
return this;
}
public VoxelShaper withShape(VoxelShape shape, Direction facing) {
shapes.put(facing, shape);
return this;
}
public static Direction axisAsFace(Axis axis) {
return Direction.get(AxisDirection.POSITIVE, axis);
}
protected static float horizontalAngleFromDirection(Direction direction) {
return (float) ((Math.max(direction.get2DDataValue(), 0) & 3) * 90);
}
protected static VoxelShaper forDirectionsWithRotation(VoxelShape shape, Direction facing,
Iterable<Direction> directions, Function<Direction, Vec3> rotationValues) {
VoxelShaper voxelShaper = new VoxelShaper();
for (Direction dir : directions) {
voxelShaper.shapes.put(dir, rotate(shape, facing, dir, rotationValues));
}
return voxelShaper;
}
protected static VoxelShape rotate(VoxelShape shape, Direction from, Direction to,
Function<Direction, Vec3> usingValues) {
if (from == to)
return shape;
return rotatedCopy(shape, usingValues.apply(from)
.reverse()
.add(usingValues.apply(to)));
}
protected static VoxelShape rotatedCopy(VoxelShape shape, Vec3 rotation) {
if (rotation.equals(Vec3.ZERO))
return shape;
MutableObject<VoxelShape> result = new MutableObject<>(Shapes.empty());
Vec3 center = new Vec3(8, 8, 8);
shape.forAllBoxes((x1, y1, z1, x2, y2, z2) -> {
Vec3 v1 = new Vec3(x1, y1, z1).scale(16)
.subtract(center);
Vec3 v2 = new Vec3(x2, y2, z2).scale(16)
.subtract(center);
v1 = VecHelper.rotate(v1, (float) rotation.x, Axis.X);
v1 = VecHelper.rotate(v1, (float) rotation.y, Axis.Y);
v1 = VecHelper.rotate(v1, (float) rotation.z, Axis.Z)
.add(center);
v2 = VecHelper.rotate(v2, (float) rotation.x, Axis.X);
v2 = VecHelper.rotate(v2, (float) rotation.y, Axis.Y);
v2 = VecHelper.rotate(v2, (float) rotation.z, Axis.Z)
.add(center);
VoxelShape rotated = blockBox(v1, v2);
result.setValue(Shapes.or(result.getValue(), rotated));
});
return result.getValue();
}
protected static VoxelShape blockBox(Vec3 v1, Vec3 v2) {
return Block.box(
Math.min(v1.x, v2.x),
Math.min(v1.y, v2.y),
Math.min(v1.z, v2.z),
Math.max(v1.x, v2.x),
Math.max(v1.y, v2.y),
Math.max(v1.z, v2.z)
);
}
protected static class DefaultRotationValues implements Function<Direction, Vec3> {
// assume facing up as the default rotation
@Override
public Vec3 apply(Direction direction) {
return new Vec3(direction == Direction.UP ? 0 : (Direction.Plane.VERTICAL.test(direction) ? 180 : 90),
-horizontalAngleFromDirection(direction), 0);
}
}
protected static class HorizontalRotationValues implements Function<Direction, Vec3> {
@Override
public Vec3 apply(Direction direction) {
return new Vec3(0, -horizontalAngleFromDirection(direction), 0);
}
}
}

View File

@@ -0,0 +1,25 @@
package com.oierbravo.mechanicals_ui;
import com.mojang.logging.LogUtils;
import net.minecraft.resources.ResourceLocation;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModContainer;
import net.neoforged.fml.common.Mod;
import org.slf4j.Logger;
@Mod(MechanicalsUI.MODID)
public class MechanicalsUI {
public static final String MODID = "mechanicals_ui";
private static final Logger LOGGER = LogUtils.getLogger();
public MechanicalsUI(IEventBus modEventBus, ModContainer modContainer) {
}
public static ResourceLocation asResource(String path) {
return ResourceLocation.fromNamespaceAndPath(MODID, path);
}
}

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui;
package com.oierbravo.mechanicals_ui.foundation.gui;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
@@ -6,8 +6,8 @@ package com.oierbravo.mechanical_lemon_ui.foundation.gui;
*/
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.widget.AbstractSimiWidget;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.Components;
import com.oierbravo.mechanicals_ui.foundation.gui.widget.AbstractSimiWidget;
import com.oierbravo.mechanicals_ui.foundation.utility.Components;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
@@ -16,8 +16,8 @@ import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import java.util.Collection;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui;
package com.oierbravo.mechanicals_ui.foundation.gui;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,13 +1,15 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.menu;
package com.oierbravo.mechanicals_ui.foundation.gui.menu;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.mojang.blaze3d.platform.InputConstants;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.TickableGuiEventListener;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.widget.AbstractSimiWidget;
import com.oierbravo.mechanical_lemon_ui.register.LibGuiTextures;
import com.oierbravo.mechanicals_ui.register.LibGuiTextures;
import net.createmod.catnip.animation.AnimationTickHolder;
import net.createmod.catnip.gui.TickableGuiEventListener;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
@@ -17,22 +19,25 @@ import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.lwjgl.glfw.GLFW;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@OnlyIn(Dist.CLIENT)
@ParametersAreNonnullByDefault
public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMenu> extends AbstractContainerScreen<T> {
protected int titleXOffset = 2;
protected int titleYOffset = 6;
protected int windowXOffset, windowYOffset;
public AbstractSimiContainerScreen(T container, Inventory inv, Component title) {
@@ -96,11 +101,15 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
}
}
/*@Override
public void renderBackground(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) {
NeoForge.EVENT_BUS.post(new ContainerScreenEvent.Render.Background(this, pGuiGraphics, pMouseX, pMouseY));
renderBg(pGuiGraphics, pPartialTick, pMouseX, pMouseY);
}*/
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
partialTicks = minecraft.getFrameTime();
renderBackground(graphics);
partialTicks = AnimationTickHolder.getPartialTicksUI();
super.render(graphics, mouseX, mouseY, partialTicks);
@@ -135,24 +144,23 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
public void renderPlayerInventory(GuiGraphics graphics, int x, int y) {
LibGuiTextures.PLAYER_INVENTORY.render(graphics, x, y);
graphics.drawString(font, playerInventoryTitle, x + titleXOffset, y + titleYOffset, 0x404040, false);
graphics.drawString(font, playerInventoryTitle, x + 8, y + 6, 0x404040, false);
}
@Override
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
InputConstants.Key mouseKey = InputConstants.getKey(pKeyCode, pScanCode);
if (getFocused() instanceof EditBox && this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey))
return false;
if (getFocused() instanceof EditBox && pKeyCode != GLFW.GLFW_KEY_ESCAPE)
return getFocused().keyPressed(pKeyCode, pScanCode, pModifiers);
return super.keyPressed(pKeyCode, pScanCode, pModifiers);
}
@Override
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
if (getFocused() != null && !getFocused().isMouseOver(pMouseX, pMouseY))
setFocused(null);
return super.mouseClicked(pMouseX, pMouseY, pButton);
}
@Override
public GuiEventListener getFocused() {
GuiEventListener focused = super.getFocused();
@@ -181,8 +189,14 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
protected void debugExtraAreas(GuiGraphics graphics) {
for (Rect2i area : getExtraAreas()) {
graphics.fill(area.getX() + area.getWidth(), area.getY() + area.getHeight(), area.getX(), area.getY(),
0xD3D3D3D3);
0xD3D3D3D3);
}
}
}
protected void playUiSound(SoundEvent sound, float volume, float pitch) {
Minecraft.getInstance()
.getSoundManager()
.play(SimpleSoundInstance.forUI(sound, pitch, volume * 0.25f));
}
}

View File

@@ -1,18 +1,18 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.menu;
package com.oierbravo.mechanicals_ui.foundation.gui.menu;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.oierbravo.mechanical_lemon_ui.foundation.utility.IInteractionChecker;
import net.minecraft.network.FriendlyByteBuf;
import com.oierbravo.mechanicals_ui.foundation.utility.IInteractionChecker;
import net.minecraft.network.RegistryFriendlyByteBuf;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.inventory.Slot;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
public abstract class MenuBase<T> extends AbstractContainerMenu {
@@ -20,7 +20,7 @@ public abstract class MenuBase<T> extends AbstractContainerMenu {
public Inventory playerInventory;
public T contentHolder;
protected MenuBase(MenuType<?> type, int id, Inventory inv, FriendlyByteBuf extraData) {
protected MenuBase(MenuType<?> type, int id, Inventory inv, RegistryFriendlyByteBuf extraData) {
super(type, id);
init(inv, createOnClient(extraData));
}
@@ -40,7 +40,7 @@ public abstract class MenuBase<T> extends AbstractContainerMenu {
}
@OnlyIn(Dist.CLIENT)
protected abstract T createOnClient(FriendlyByteBuf extraData);
protected abstract T createOnClient(RegistryFriendlyByteBuf extraData);
protected abstract void initAndReadInventory(T contentHolder);
@@ -70,5 +70,5 @@ public abstract class MenuBase<T> extends AbstractContainerMenu {
return ((IInteractionChecker) contentHolder).canPlayerUse(player);
return true;
}
}

View File

@@ -1,11 +1,10 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.widget;
package com.oierbravo.mechanicals_ui.foundation.gui.widget;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.oierbravo.mechanical_lemon_ui.foundation.gui.TickableGuiEventListener;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.Components;
import com.oierbravo.mechanicals_ui.foundation.gui.TickableGuiEventListener;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;

View File

@@ -1,12 +1,13 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.widget;
package com.oierbravo.mechanicals_ui.foundation.gui.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.oierbravo.mechanical_lemon_ui.register.LibGuiTextures;
import com.oierbravo.mechanicals_ui.register.LibGuiTextures;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraftforge.energy.IEnergyStorage;
import net.neoforged.neoforge.energy.IEnergyStorage;
import org.jetbrains.annotations.NotNull;
import java.util.List;

View File

@@ -1,12 +1,13 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.widget;
package com.oierbravo.mechanicals_ui.foundation.gui.widget;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import com.mojang.blaze3d.systems.RenderSystem;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.ScreenElement;
import com.oierbravo.mechanical_lemon_ui.register.LibGuiTextures;
import com.oierbravo.mechanicals_ui.register.LibGuiTextures;
import net.createmod.catnip.gui.element.ScreenElement;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;

View File

@@ -1,6 +1,7 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.widget;
package com.oierbravo.mechanicals_ui.foundation.gui.widget;
import com.oierbravo.mechanical_lemon_ui.register.LibGuiTextures;
import com.oierbravo.mechanicals_ui.register.LibGuiTextures;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.gui.GuiGraphics;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,9 +1,9 @@
package com.oierbravo.mechanical_lemon_ui.foundation.gui.widget;
package com.oierbravo.mechanicals_ui.foundation.gui.widget;
import com.mojang.blaze3d.systems.RenderSystem;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.widget.AbstractSimiWidget;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.ScreenElement;
import com.oierbravo.mechanical_lemon_ui.register.LibGuiTextures;
import com.oierbravo.mechanicals_ui.register.LibGuiTextures;
import net.createmod.catnip.gui.element.ScreenElement;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* smashingmods
*

View File

@@ -1,7 +1,6 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
import com.mojang.blaze3d.systems.RenderSystem;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.UIRenderHelper;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
/*
@@ -9,8 +8,6 @@ import net.minecraft.resources.ResourceLocation;
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public abstract class IGuiTextures {

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,9 +1,10 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create
* License: MIT
*/
import net.createmod.catnip.math.VoxelShaper;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.phys.shapes.BooleanOp;

View File

@@ -1,4 +1,4 @@
package com.oierbravo.mechanical_lemon_ui.foundation.utility;
package com.oierbravo.mechanicals_ui.foundation.utility;
/*
* Credits: Creators of create
* https://github.com/Creators-of-Create/Create

View File

@@ -1,16 +1,16 @@
package com.oierbravo.mechanical_lemon_ui.register;
package com.oierbravo.mechanicals_ui.register;
import com.mojang.blaze3d.systems.RenderSystem;
import com.oierbravo.mechanical_lemon_ui.MechanicalLemonUI;
import com.oierbravo.mechanical_lemon_ui.foundation.gui.UIRenderHelper;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.Color;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.ScreenElement;
import com.oierbravo.mechanicals_ui.MechanicalsUI;
import net.createmod.catnip.gui.UIRenderHelper;
import net.createmod.catnip.gui.element.ScreenElement;
import net.createmod.catnip.theme.Color;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
public enum LibGuiTextures implements ScreenElement {
public enum LibGuiTextures implements ScreenElement {
PLAYER_INVENTORY("player_inventory", 176, 108),
@@ -38,11 +38,11 @@ public enum LibGuiTextures implements ScreenElement {
}
private LibGuiTextures(String location, int startX, int startY, int width, int height) {
this(MechanicalLemonUI.MODID, location, startX, startY, width, height);
this(MechanicalsUI.MODID, location, startX, startY, width, height);
}
private LibGuiTextures(String namespace, String location, int startX, int startY, int width, int height) {
this.location = new ResourceLocation(namespace, "textures/gui/" + location + ".png");
this.location = ResourceLocation.fromNamespaceAndPath(namespace, "textures/gui/" + location + ".png");
this.width = width;
this.height = height;
this.startX = startX;

View File

@@ -1,22 +1,22 @@
package com.oierbravo.mechanical_lemon_ui.register;
package com.oierbravo.mechanicals_ui.register;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.oierbravo.mechanical_lemon_ui.MechanicalLemonUI;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.Color;
import com.oierbravo.mechanical_lemon_ui.foundation.utility.ScreenElement;
import com.oierbravo.mechanicals_ui.MechanicalsUI;
import net.createmod.catnip.gui.element.ScreenElement;
import net.createmod.catnip.theme.Color;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.api.distmarker.OnlyIn;
import org.joml.Matrix4f;
public class LibIcons implements ScreenElement {
public static final ResourceLocation ICON_ATLAS = MechanicalLemonUI.asResource("textures/gui/icons.png");
public static final ResourceLocation ICON_ATLAS = MechanicalsUI.asResource("textures/gui/icons.png");
public static final int ICON_ATLAS_SIZE = 256;
private static int x = 0;
private static int y = -1;
@@ -80,6 +80,9 @@ public class LibIcons implements ScreenElement {
@OnlyIn(Dist.CLIENT)
private void vertex(VertexConsumer builder, Matrix4f matrix, Vec3 vec, Color rgb, float u, float v, int light) {
builder.vertex(matrix, (float)vec.x, (float)vec.y, (float)vec.z).color(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255).uv(u, v).uv2(light).endVertex();
builder.addVertex(matrix, (float) vec.x, (float) vec.y, (float) vec.z)
.setColor(rgb.getRed(), rgb.getGreen(), rgb.getBlue(), 255)
.setUv(u, v)
.setLight(light);
}
}

View File

@@ -1,24 +0,0 @@
modLoader = "javafml" #mandatory
loaderVersion = "${loader_version_range}" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
license = "${mod_license}"
[[mods]] #mandatory
modId = "${modid}" #mandatory
version = "${mod_version}" #mandatory
displayName = "${mod_name}" #mandatory
authors = "${author}" #optional
description = '''${mod_description}'''
[[dependencies."${modid}"]] #optional
modId = "forge" #mandatory
mandatory = true #mandatory
versionRange = "${forge_version_range}" #mandatory
ordering = "NONE"
side = "BOTH"# Here's another dependency
[[dependencies."${modid}"]]
modId = "minecraft"
mandatory = true
versionRange = "${minecraft_version_range}"
ordering = "NONE"
side = "BOTH"

View File

@@ -0,0 +1,27 @@
modLoader = "javafml" #mandatory
loaderVersion = "[0,)"# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
license = "${mod_license}"
[[mods]] #mandatory
modId = "${mod_id}" #mandatory
version = "${mod_version}" #mandatory
displayName = "${mod_name}" #mandatory
#updateJSONURL="https://change.me.example.invalid/updates.json" #optional
#displayURL="https://change.me.to.your.mods.homepage.example.invalid/" #optional
#logoFile="mechanicals_lib.png" #optional
#credits="Thanks for this example mod goes to Java" #optional
authors = "${mod_author}" #optional
description = '''${mod_description}'''
[[dependencies."${mod_id}"]]
modId="neoforge"
type="required"
versionRange="${neo_version_range}"
ordering="NONE"
side="BOTH"
[[dependencies."${mod_id}"]]
modId="minecraft"
type="required"
versionRange="${minecraft_version_range}"
ordering="NONE"
side="BOTH"

View File

Before

Width:  |  Height:  |  Size: 809 B

After

Width:  |  Height:  |  Size: 809 B

View File

@@ -1,6 +0,0 @@
{
"pack": {
"description": "mechanical_lemon_ui resources",
"pack_format": 15
}
}