Skip to content

Commit

Permalink
Feature/modular gui (#451)
Browse files Browse the repository at this point in the history
* Modular GUI Implementation.

* First round of tweaks based on covers feedback.

* Made requested changes

* Update JEI maven
  • Loading branch information
brandon3055 authored Jan 26, 2024
1 parent b4954cf commit 9fbd40b
Show file tree
Hide file tree
Showing 103 changed files with 12,599 additions and 3 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ configurations {
repositories {
mavenLocal()
maven { url "https://maven.covers1624.net/" }
maven { url "https://maven.blamejared.com/" }
}

dependencies {
Expand All @@ -81,6 +82,9 @@ dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'

compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}"))
compileOnly(fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}"))
}

test {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ org.gradle.daemon=false
mc_version=1.20.1
forge_version=47.1.65
mod_version=4.4.0
jei_version=15.2.0.27
72 changes: 72 additions & 0 deletions src/main/java/codechicken/lib/colour/Colour.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,78 @@ public Colour set(float[] floats) {
return set(floats[0], floats[1], floats[2], floats[3]);
}

public Colour rF(float r) {
this.r = (byte) (255F * r);
return this;
}

public Colour gF(float g) {
this.g = (byte) (255F * g);
return this;
}

public Colour bF(float b) {
this.b = (byte) (255F * b);
return this;
}

public Colour aF(float a) {
this.a = (byte) (255F * a);
return this;
}

public Colour rF(int r) {
this.r = (byte) r;
return this;
}

public Colour gF(int g) {
this.g = (byte) g;
return this;
}

public Colour bF(int b) {
this.b = (byte) b;
return this;
}

public Colour aF(int a) {
this.a = (byte) a;
return this;
}

public float rF() {
return r / 255F;
}

public float gF() {
return g / 255F;
}

public float bF() {
return b / 255F;
}

public float aF() {
return a / 255F;
}

public int r() {
return r & 0xFF;
}

public int g() {
return g & 0xFF;
}

public int b() {
return b & 0xFF;
}

public int a() {
return a & 0xFF;
}

/**
* Flips a color between ABGR and RGBA.
*
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/codechicken/lib/compat/JEIPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package codechicken.lib.compat;

import codechicken.lib.CodeChickenLib;
import codechicken.lib.gui.modular.ModularGuiContainer;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.JeiPlugin;
import mezz.jei.api.gui.handlers.IGuiContainerHandler;
import mezz.jei.api.registration.IGuiHandlerRegistration;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.resources.ResourceLocation;

import java.util.List;

/**
* Created by brandon3055 on 31/12/2023
*/
@JeiPlugin
public class JEIPlugin implements IModPlugin {
private static final ResourceLocation ID = new ResourceLocation(CodeChickenLib.MOD_ID, "jei_plugin");

public JEIPlugin() {}

@Override
public ResourceLocation getPluginUid() {
return ID;
}

@Override
public void registerGuiHandlers(IGuiHandlerRegistration registration) {
registration.addGuiContainerHandler(ModularGuiContainer.class, new IGuiContainerHandler<>() {
@Override
public List<Rect2i> getGuiExtraAreas(ModularGuiContainer screen) {
return screen.getModularGui().getJeiExclusions().map(e -> e.getRectangle().toRect2i()).toList();
}
});
}
}
Loading

0 comments on commit 9fbd40b

Please sign in to comment.