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
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.11-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

archivesBaseName = project.archives_base_name
version = project.mod_version
Expand Down Expand Up @@ -53,7 +53,7 @@ tasks.withType(JavaCompile) {
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
archiveClassifier = "sources"
from sourceSets.main.allSource
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ 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
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
loader_version=0.15.11


# Mod Properties
Expand All @@ -17,5 +17,5 @@ org.gradle.jvmargs=-Xmx1G

# 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
fabric_version=0.98.0+1.20.6
modmenu_version=10.0.0-beta.1
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu May 16 19:52:53 CEST 2024
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
33 changes: 14 additions & 19 deletions src/main/java/net/entityoutliner/ui/ColorWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

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.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.text.Text;
Expand All @@ -20,12 +18,11 @@
public class ColorWidget extends PressableWidget {
private static final Identifier TEXTURE = new Identifier("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);
this.entityType = entityType;

if (EntitySelector.outlinedEntityTypes.containsKey(this.entityType))
onShow();
}
Expand All @@ -39,20 +36,18 @@ public void onShow() {
}

public void onPress() {
System.out.println("asdasd");
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(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 static final 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
56 changes: 26 additions & 30 deletions src/main/java/net/entityoutliner/ui/EntityListWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,28 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.gui.DrawContext;
import org.apache.commons.lang3.StringUtils;

import net.entityoutliner.ui.ColorWidget.Color;
import net.fabricmc.api.EnvType;
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.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 top, int itemHeight) {
super(client, width, height, top, itemHeight);
this.centerListVertically = false;
}

Expand All @@ -41,8 +40,9 @@ 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 +62,30 @@ 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) {
return new EntityListWidget.EntityEntry(
new CheckboxWidget(width / 2 - 155, 0, 310, 20, entityType.getName(), EntitySelector.outlinedEntityTypes.containsKey(entityType)),
new ColorWidget(width / 2 + 130, 0, 310, 20, entityType),
CheckboxWidget.builder(entityType.getName(), MinecraftClient.getInstance().textRenderer).pos(width / 2 - 155, 0).checked(EntitySelector.outlinedEntityTypes.containsKey(entityType)).build(),
new ColorWidget(width / 2 + 130, 0, 100, 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 @@ -101,25 +103,17 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
this.checkbox.onPress();
this.children.add(this.color);
}

return true;
}
}

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

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

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

public List<? extends Selectable> selectableChildren() {
return this.children;
}

}

@Environment(EnvType.CLIENT)
Expand All @@ -136,11 +130,11 @@ private HeaderEntry(SpawnGroup category, TextRenderer font, int width, int heigh
this.height = height;

if (category != null) {
String title = "";
for (String term : category.getName().split("\\p{Punct}|\\p{Space}")) {
title += StringUtils.capitalize(term) + " ";
StringBuilder title = new StringBuilder();
for (String term : category.getName().split("\\p{Punct}|\\s")) {
title.append(StringUtils.capitalize(term)).append(" ");
}
this.title = title.trim();
this.title = title.toString().trim();
} else {
this.title = Language.getInstance().get("gui.entity-outliner.no_results");
}
Expand All @@ -151,8 +145,9 @@ 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 index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
context.drawCenteredTextWithShadow(MinecraftClient.getInstance().textRenderer, this.title, this.width / 2, y + (this.height / 2) - (this.font.fontHeight / 2), 16777215);
}

public List<? extends Element> children() {
Expand All @@ -167,5 +162,6 @@ public String toString() {
public List<? extends Selectable> selectableChildren() {
return new ArrayList<>();
}

}
}
Loading