Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 21 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.4.5'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

Expand All @@ -30,31 +26,35 @@ dependencies {
compileOnly 'com.google.code.findbugs:jsr305:+'
}

base {
archivesName = project.archives_base_name
}

processResources {
inputs.property "version", project.version

filesMatching("fabric.mod.json") {
expand "version": project.version
}

// from(sourceSets.main.resources.srcDirs) {
// exclude "fabric.mod.json"
// }
}

// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
it.options.encoding = "UTF-8"
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

jar {
Expand All @@ -74,10 +74,4 @@ publishing {
}
}
}

// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
}
23 changes: 10 additions & 13 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@
org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.5
loader_version=0.14.13

# check these on https://fabricmc.net/use
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10

# Mod Properties
mod_version = 1.2.6
maven_group = net.entityoutliner
archives_base_name = entity-outliner


mod_version = 1.2.6_1.21.4
maven_group = net.entityoutliner
archives_base_name = entity-outliner

# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.73.0+1.19.3
modmenu_version=5.0.2
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.91.1+1.20.4
modmenu_version=9.0.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
35 changes: 15 additions & 20 deletions src/main/java/net/entityoutliner/ui/ColorWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

import java.util.Map;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

@Environment(EnvType.CLIENT)
public class ColorWidget extends PressableWidget {
private static final Identifier TEXTURE = new Identifier("entityoutliner:textures/gui/colors.png");
private static final Identifier TEXTURE = Identifier.of("entityoutliner:textures/gui/colors.png");
private Color color;
private EntityType<?> entityType;
private final EntityType<?> entityType;

private ColorWidget(int x, int y, int width, int height, Text message, EntityType<?> entityType) {
super(x, y, width, height, message);
Expand All @@ -38,21 +36,18 @@ public void onShow() {
this.color = EntitySelector.outlinedEntityTypes.get(this.entityType);
}

@Override
public void onPress() {
this.color = this.color.next();
EntitySelector.outlinedEntityTypes.put(this.entityType, this.color);
}

public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
MinecraftClient minecraftClient = MinecraftClient.getInstance();
RenderSystem.setShaderTexture(0, TEXTURE);
RenderSystem.enableDepthTest();
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
@Override
protected void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
//context.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA);
drawTexture(matrices, this.getX(), this.getY(), this.isFocused() ? 20.0F : 0.0F, this.color.ordinal() * 20, 20, 20, 40, 180);
this.renderBackground(matrices, minecraftClient, mouseX, mouseY);
RenderSystem.enableDepthTest();
context.drawTexture(RenderLayer::getGuiTexturedOverlay, TEXTURE, this.getX(), this.getY(), this.isFocused() ? 20.0F : 0.0F, this.color.ordinal() * 20, 20, 20, 40, 180);
}

public enum Color {
Expand All @@ -66,9 +61,9 @@ public enum Color {
PURPLE(127, 0, 127),
PINK(255, 155, 182);

public int red;
public int green;
public int blue;
public final int red;
public final int green;
public final int blue;

private static final Map<SpawnGroup, Color> spawnGroupColors = Map.of(
SpawnGroup.AMBIENT, Color.PURPLE,
Expand All @@ -81,9 +76,9 @@ public enum Color {
SpawnGroup.WATER_CREATURE, Color.BLUE
);

private static Color[] colors = Color.values();
private final static Color[] colors = Color.values();

private Color(int red, int green, int blue) {
Color(int red, int green, int blue) {
this.red = red;
this.green = green;
this.blue = blue;
Expand Down
62 changes: 35 additions & 27 deletions src/main/java/net/entityoutliner/ui/EntityListWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.widget.CheckboxWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.gui.widget.PressableWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.Language;

@Environment(EnvType.CLIENT)
public class EntityListWidget extends ElementListWidget<EntityListWidget.Entry> {

public EntityListWidget(MinecraftClient client, int width, int height, int top, int bottom, int itemHeight) {
super(client, width, height, top, bottom, itemHeight);
public EntityListWidget(MinecraftClient client, int width, int height, int y, int itemHeight) {
super(client, width, height, y, itemHeight);
this.centerListVertically = false;
}

Expand All @@ -37,12 +36,14 @@ public void clearListEntries() {
super.clearEntries();
}

@Override
public int getRowWidth() {
return 400;
}

protected int getScrollbarPositionX() {
return super.getScrollbarPositionX() + 32;
@Override
protected int getScrollbarX() {
return super.getScrollbarX() + 32;
}

@Environment(EnvType.CLIENT)
Expand All @@ -62,28 +63,36 @@ private EntityEntry(CheckboxWidget checkbox, ColorWidget color, EntityType<?> en
this.color = color;

this.children.add(checkbox);
if (EntitySelector.outlinedEntityTypes.containsKey(entityType))
if (EntitySelector.outlinedEntityTypes.containsKey(entityType))
this.children.add(color);
}

public static EntityListWidget.EntityEntry create(EntityType<?> entityType, int width) {
public static EntityListWidget.EntityEntry create(EntityType<?> entityType, int width, TextRenderer font) {
final CheckboxWidget checkbox = CheckboxWidget.builder(entityType.getName(), font)
.pos(width / 2 - 155, 0)
.checked(EntitySelector.outlinedEntityTypes.containsKey(entityType))
.build();
checkbox.setWidth(310);
checkbox.setHeight(20);
return new EntityListWidget.EntityEntry(
new CheckboxWidget(width / 2 - 155, 0, 310, 20, entityType.getName(), EntitySelector.outlinedEntityTypes.containsKey(entityType)),
checkbox,
new ColorWidget(width / 2 + 130, 0, 310, 20, entityType),
entityType
);
}

public void render(MatrixStack matrices, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
this.checkbox.setY(j);
this.checkbox.render(matrices, n, o, f);
@Override
public void render(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
this.checkbox.setY(y);
this.checkbox.render(context, mouseX, mouseY, tickDelta);

if (this.children.contains(this.color)) {
this.color.setY(j);
this.color.render(matrices, n, o, f);
this.color.setY(y);
this.color.render(context, mouseX, mouseY, tickDelta);
}
}

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (EntitySelector.outlinedEntityTypes.containsKey(entityType)) {
if (this.color.isMouseOver(mouseX, mouseY)) {
Expand All @@ -105,18 +114,12 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return true;
}

@Override
public List<? extends Element> children() {
return this.children;
}

public EntityType<?> getEntityType() {
return this.entityType;
}

public CheckboxWidget getCheckbox() {
return this.checkbox;
}

@Override
public List<? extends Selectable> selectableChildren() {
return this.children;
}
Expand All @@ -136,11 +139,13 @@ private HeaderEntry(SpawnGroup category, TextRenderer font, int width, int heigh
this.height = height;

if (category != null) {
String title = "";
StringBuilder title = new StringBuilder();
for (String term : category.getName().split("\\p{Punct}|\\p{Space}")) {
title += StringUtils.capitalize(term) + " ";
title.append(StringUtils.capitalize(term));
title.append(' ');
}
this.title = title.trim();
title.deleteCharAt(title.length() - 1);
this.title = title.toString();
} else {
this.title = Language.getInstance().get("gui.entity-outliner.no_results");
}
Expand All @@ -151,14 +156,17 @@ public static EntityListWidget.HeaderEntry create(SpawnGroup category, TextRende
return new EntityListWidget.HeaderEntry(category, font, width, height);
}

public void render(MatrixStack matrices, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
DrawableHelper.drawCenteredText(matrices, this.font, this.title, this.width / 2, j + (this.height / 2) - (this.font.fontHeight / 2), 16777215);
@Override
public void render(DrawContext context, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
context.drawCenteredTextWithShadow(this.font, this.title, this.width / 2, j + (this.height / 2) - (this.font.fontHeight / 2), 16777215);
}

@Override
public List<? extends Element> children() {
return new ArrayList<>();
}

@Override
public String toString() {
return this.title;
}
Expand Down
Loading