Skip to content

Commit

Permalink
WIP config file
Browse files Browse the repository at this point in the history
  • Loading branch information
r8420 committed Aug 5, 2024
1 parent 1aa5496 commit 5264d1d
Show file tree
Hide file tree
Showing 13 changed files with 164 additions and 148 deletions.
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ repositories {
name = "ModMaven"
url = "https://modmaven.dev"
}
maven { url 'https://maven.wispforest.io/releases/' }
maven {
name = "Terraformers"
url = "https://maven.terraformersmc.com/"
}
}

loom {
Expand Down Expand Up @@ -53,10 +58,14 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

modCompileOnlyApi("mezz.jei:jei-1.20.4-common-api:17.3.0.52")
modCompileOnlyApi("mezz.jei:jei-1.20.4-fabric-api:17.3.0.52")
modCompileOnlyApi("mezz.jei:jei-${project.jei_minecraft_version}-common-api:${project.jei_version}")
modCompileOnlyApi("mezz.jei:jei-${project.jei_minecraft_version}-fabric-api:${project.jei_version}")
// at runtime, use the full JEI jar for Fabric
modRuntimeOnly("mezz.jei:jei-1.20.4-fabric:17.3.0.52")
modRuntimeOnly("mezz.jei:jei-${project.jei_minecraft_version}-fabric:${project.jei_version}")

annotationProcessor modImplementation("io.wispforest:owo-lib:${project.owo_version}")

modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")

// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
Expand Down
13 changes: 10 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.15.11

# Fabric API
fabric_version=0.97.0+1.20.4
fabric_version=0.92.2+1.20.1

# Mod Properties
mod_version=1.22.4.2-fabric
maven_group=at.ridgo8.moreoverlays
archives_base_name=moreoverlays

# Config Properties
owo_version=0.11.2+1.20
modmenu_version=7.2.2

# Dependencies Properties
jei_minecraft_version=1.20.1
jei_version=15.10.0.29
6 changes: 3 additions & 3 deletions src/client/java/at/ridgo8/moreoverlays/MoreOverlays.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import at.ridgo8.moreoverlays.chunkbounds.ChunkBoundsHandler;
import at.ridgo8.moreoverlays.chunkbounds.ChunkBoundsHandler.RenderMode;
import at.ridgo8.moreoverlays.config.Config;
import at.ridgo8.moreoverlays.itemsearch.GuiRenderer;
import at.ridgo8.moreoverlays.config.MoreOverlaysConfig;
import at.ridgo8.moreoverlays.lightoverlay.LightOverlayHandler;

import org.apache.logging.log4j.LogManager;
Expand All @@ -23,6 +22,8 @@ public class MoreOverlays implements ModInitializer {

public static Logger logger = LogManager.getLogger(NAME);

public static MoreOverlaysConfig Config = MoreOverlaysConfig.createAndLoad();

@Override
public void onInitialize() {

Expand All @@ -44,7 +45,6 @@ public void onInitialize() {
});


Config.initialize();
ClientRegistrationHandler.setupClient();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.ridgo8.moreoverlays.api.lightoverlay;

import at.ridgo8.moreoverlays.config.Config;
import static at.ridgo8.moreoverlays.MoreOverlays.Config;
import net.minecraft.core.Holder;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.entity.player.Player;
Expand All @@ -22,9 +22,9 @@ public void update(Player player) {
int py = (int) Math.floor(player.getY());
int pz = (int) Math.floor(player.getZ());

int y1 = py - Config.light_DownRange;
int y2 = py + Config.light_UpRange;
int HRange = Config.light_HRange;
int y1 = py - Config.light_DownRange();
int y2 = py + Config.light_UpRange();
int HRange = Config.light_HRange();

overlayCache.clear();

Expand Down Expand Up @@ -82,7 +82,7 @@ public boolean shouldCheck(BlockPos pos, Level world) {
if(world.isClientSide){
return true;
}
if (Config.light_IgnoreSpawnList) {
if (Config.light_IgnoreSpawnList()) {
return true;
}
Holder<Biome> biome = world.getBiome(pos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.ridgo8.moreoverlays.chunkbounds;

import at.ridgo8.moreoverlays.config.Config;
import static at.ridgo8.moreoverlays.MoreOverlays.Config;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import org.joml.Matrix4d;
Expand All @@ -18,7 +18,7 @@ public static void renderOverlays(PoseStack matrixstack) {

RenderSystem.enableDepthTest();
RenderSystem.disableBlend();
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth);
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth());
RenderSystem.setShader(GameRenderer::getPositionColorShader);


Expand Down Expand Up @@ -67,10 +67,10 @@ public static void renderOverlays(PoseStack matrixstack) {
final int regionBorderY1 = regionBorderY0 + (ChunkBoundsHandler.REGION_SIZEY_CUBIC * 16) - 128;
final int regionBorderZ1 = regionBorderZ0 + (ChunkBoundsHandler.REGION_SIZEZ * 16);

final int radius = Config.chunk_EdgeRadius * 16;
final int renderColorEdge = Config.render_chunkEdgeColor;
final int renderColorMiddle = Config.render_chunkMiddleColor;
final int renderColorGrid = Config.render_chunkGridColor;
final int radius = Config.chunk_EdgeRadius() * 16;
final int renderColorEdge = Config.render_chunkEdgeColor().rgb();
final int renderColorMiddle = Config.render_chunkMiddleColor().rgb();
final int renderColorGrid = Config.render_chunkGridColor().rgb();


for (int xo = -16 - radius; xo <= radius; xo += 16) {
Expand All @@ -79,7 +79,7 @@ public static void renderOverlays(PoseStack matrixstack) {
}
}

if (Config.chunk_ShowMiddle) {
if (Config.chunk_ShowMiddle()) {
renderEdge(matrixstack, x2, z2, h3, h, renderColorMiddle);
}

Expand Down
64 changes: 0 additions & 64 deletions src/client/java/at/ridgo8/moreoverlays/config/Config.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package at.ridgo8.moreoverlays.config;
import at.ridgo8.moreoverlays.MoreOverlays;
import io.wispforest.owo.config.annotation.Config;
import io.wispforest.owo.config.annotation.Modmenu;
import io.wispforest.owo.config.annotation.RangeConstraint;
import io.wispforest.owo.config.annotation.SectionHeader;
import io.wispforest.owo.ui.core.Color;


@Modmenu(modId = MoreOverlays.MOD_ID)
@Config(name = MoreOverlays.MOD_ID + "-config-fabric", wrapperName = "MoreOverlaysConfig")
public class MoreOverlaysConfigModel {

@SectionHeader("lightoverlay")
@RangeConstraint(min = 0, max = 255)
public int light_UpRange = 4;
@RangeConstraint(min = 0, max = 255)
public int light_DownRange = 16;
@RangeConstraint(min = 0, max = 255)
public int light_HRange = 16;
public boolean light_IgnoreLayer = false;
public boolean light_IgnoreSpawnList = false;
public boolean light_SimpleEntityCheck = false;
@RangeConstraint(min = 0, max = 16)
public int light_SaveLevel = 1;

@SectionHeader("chunkbounds")
@RangeConstraint(min = 0, max = 255)
public int chunk_EdgeRadius = 1;
public boolean chunk_ShowMiddle = true;

@SectionHeader("rendersettings")
public Color render_chunkEdgeColor = Color.ofRgb(0xFF0000);
public Color render_chunkGridColor = Color.ofRgb(0x00FF00);
public Color render_chunkMiddleColor = Color.ofRgb(0xFFFF00);
@RangeConstraint(min = 0d, max = 16d)
public double render_chunkLineWidth = 1.5;
public Color render_spawnAColor = Color.ofRgb(0xFF0000);
public Color render_spawnNColor = Color.ofRgb(0xFFFF00);
@RangeConstraint(min = 0d, max = 16d)
public double render_spawnLineWidth = 2;

@SectionHeader("itemsearch")
public boolean search_enabled = true;
public boolean search_searchCustom = true;
public Color search_searchBoxColor = Color.ofRgb(0xFFFF00);
public Color search_filteredSlotColor = Color.ofRgb(0x000000);
@RangeConstraint(min = 0d, max = 1d)
public double search_filteredSlotTransparancy = 0.5d;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.Vec2;

import java.util.List;
import java.util.Map;

public class GuiRenderer {
Expand Down Expand Up @@ -176,6 +177,10 @@ private void checkSlots(AbstractContainerScreen<?> container) {
} else {
views.clear();
}

List<ItemStack> filteredIngredients = JeiModule.filter.getFilteredIngredients(VanillaTypes.ITEM_STACK);
// if(filteredIngredients.size() > Config.search_maxResults.get()) return;

for (Slot slot : container.getMenu().slots) {
SlotViewWrapper wrapper;
if (!views.containsKey(slot)) {
Expand All @@ -185,14 +190,14 @@ private void checkSlots(AbstractContainerScreen<?> container) {
wrapper = views.get(slot);
}

wrapper.setEnableOverlay(wrapper.getView().canSearch() && !isSearchedItem(slot.getItem()));
wrapper.setEnableOverlay(wrapper.getView().canSearch() && !isSearchedItem(slot.getItem(), filteredIngredients));
}
}

private boolean isSearchedItem(ItemStack stack) {
private boolean isSearchedItem(ItemStack stack,List<ItemStack> filteredIngredients) {
if (emptyFilter) return true;
else if (stack.isEmpty()) return false;
for (Object ingredient : JeiModule.filter.getFilteredIngredients(VanillaTypes.ITEM_STACK)) {
for (Object ingredient : filteredIngredients) {
if (ItemUtils.ingredientMatches(ingredient, stack)) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import at.ridgo8.moreoverlays.api.lightoverlay.ILightRenderer;
import at.ridgo8.moreoverlays.api.lightoverlay.ILightScanner;
import at.ridgo8.moreoverlays.api.lightoverlay.LightOverlayReloadHandlerEvent;
import at.ridgo8.moreoverlays.config.Config;
import static at.ridgo8.moreoverlays.MoreOverlays.Config;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;

Expand Down Expand Up @@ -47,7 +47,7 @@ public static void reloadHandler() {
}

private static void reloadHandlerInternal() {
LightOverlayReloadHandlerEvent event = new LightOverlayReloadHandlerEvent(Config.light_IgnoreSpawnList, LightOverlayRenderer.class, LightScannerVanilla.class);
LightOverlayReloadHandlerEvent event = new LightOverlayReloadHandlerEvent(Config.light_IgnoreSpawnList(), LightOverlayRenderer.class, LightScannerVanilla.class);

if (renderer == null || renderer.getClass() != event.getRenderer()) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import at.ridgo8.moreoverlays.api.lightoverlay.ILightRenderer;
import at.ridgo8.moreoverlays.api.lightoverlay.ILightScanner;
import at.ridgo8.moreoverlays.config.Config;
import static at.ridgo8.moreoverlays.MoreOverlays.Config;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
import org.joml.Matrix4d;
Expand Down Expand Up @@ -85,21 +85,21 @@ private static void drawVertex(Matrix4d matrix, double x, double y, double z, fl
public void renderOverlays(ILightScanner scanner, PoseStack matrixstack) {
RenderSystem.enableDepthTest();
RenderSystem.disableBlend();
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth);
RenderSystem.lineWidth((float) (double) Config.render_chunkLineWidth());
RenderSystem.setShader(GameRenderer::getPositionColorShader);

if (Minecraft.getInstance().options.graphicsMode().get() != GraphicsStatus.FABULOUS) {
RenderSystem.depthMask(false);
RenderSystem.enableCull();
}

float ar = ((float) ((Config.render_spawnAColor >> 16) & 0xFF)) / 255F;
float ag = ((float) ((Config.render_spawnAColor >> 8) & 0xFF)) / 255F;
float ab = ((float) (Config.render_spawnAColor & 0xFF)) / 255F;
float ar = ((float) ((Config.render_spawnAColor().rgb() >> 16) & 0xFF)) / 255F;
float ag = ((float) ((Config.render_spawnAColor().rgb() >> 8) & 0xFF)) / 255F;
float ab = ((float) (Config.render_spawnAColor().rgb() & 0xFF)) / 255F;

float nr = ((float) ((Config.render_spawnNColor >> 16) & 0xFF)) / 255F;
float ng = ((float) ((Config.render_spawnNColor >> 8) & 0xFF)) / 255F;
float nb = ((float) (Config.render_spawnNColor & 0xFF)) / 255F;
float nr = ((float) ((Config.render_spawnNColor().rgb() >> 16) & 0xFF)) / 255F;
float ng = ((float) ((Config.render_spawnNColor().rgb() >> 8) & 0xFF)) / 255F;
float nb = ((float) (Config.render_spawnNColor().rgb() & 0xFF)) / 255F;

renderer.begin(VertexFormat.Mode.DEBUG_LINES, DefaultVertexFormat.POSITION_COLOR);
for (Pair<BlockPos, Byte> entry : scanner.getLightModes()) {
Expand Down
Loading

0 comments on commit 5264d1d

Please sign in to comment.