Skip to content

Commit

Permalink
Updated to 1.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
adamviola committed Dec 8, 2020
1 parent f20fbfa commit bb35fea
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 138 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ bin/
.classpath
.project

# macos

*.DS_Store

# fabric

run/
54 changes: 28 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '0.2.7-SNAPSHOT'
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'maven-publish'
}

Expand All @@ -11,51 +11,53 @@ version = project.mod_version
group = project.maven_group

dependencies {
//to change the versions see the gradle.properties file
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"

// modApi "me.shedaniel.cloth:config-2:2.14.1"
// include "me.shedaniel.cloth:config-2:2.14.1"

// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}

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

from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
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 {
// 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
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}

// 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()
}

jar {
from "LICENSE"
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
Expand All @@ -72,9 +74,9 @@ publishing {
}
}

// select the repositories you want to publish to
// Select the repositories you want to publish to
// To publish to maven local, no extra repositories are necessary. Just use the task `publishToMavenLocal`.
repositories {
// uncomment to publish to the local maven
// mavenLocal()
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
}
}
10 changes: 4 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.15.2
yarn_mappings=1.15.2+build.15
loader_version=0.8.4+build.198
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.7
loader_version=0.10.8

# Mod Properties
mod_version = 1.0.0
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.10.8+build.310-1.15
fabric_version=0.27.1+1.16
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
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-6.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 2 additions & 0 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ esac

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar


# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
Expand Down Expand Up @@ -129,6 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`

JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
Expand Down
22 changes: 4 additions & 18 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand All @@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
Expand All @@ -64,28 +64,14 @@ echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/net/entityoutliner/EntityListWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.widget.CheckboxWidget;
import net.minecraft.client.gui.widget.ElementListWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.EntityType;

@Environment(EnvType.CLIENT)
Expand All @@ -37,8 +38,8 @@ public int getRowWidth() {
return 400;
}

protected int getScrollbarPosition() {
return super.getScrollbarPosition() + 32;
protected int getScrollbarPositionX() {
return super.getScrollbarPositionX() + 32;
}

@Override
Expand Down Expand Up @@ -74,12 +75,12 @@ private CheckboxEntry(CheckboxWidget checkbox, EntityType<?> entityType) {
}

public static EntityListWidget.CheckboxEntry create(EntityType<?> entityType, boolean checked, int width) {
return new EntityListWidget.CheckboxEntry(new CheckboxWidget(width/2 - 155, 0, 310, 20, entityType.getName().asString(), checked), entityType);
return new EntityListWidget.CheckboxEntry(new CheckboxWidget(width/2 - 155, 0, 310, 20, entityType.getName(), checked), entityType);
}

public void render(int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
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.y = j;
this.checkbox.render(n, o, f);
this.checkbox.render(matrices, n, o, f);
}

public List<? extends Element> children() {
Expand All @@ -105,23 +106,23 @@ public static class HeaderEntry extends EntityListWidget.Entry {
private final int width;
private final int height;

private final Drawer drawer;
// private final Drawer drawer;

private HeaderEntry(TextRenderer font, String title, int width, int height) {
this.font = font;
this.title = title;
this.width = width;
this.height = height;

this.drawer = new Drawer();
// this.drawer = new Drawer();
}

public static EntityListWidget.HeaderEntry create(TextRenderer font, String title, int width, int height) {
return new EntityListWidget.HeaderEntry(font, title, width, height);
}

public void render(int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
drawer.drawCenteredString(this.font, this.title, this.width / 2, j + (this.height / 2) - (this.font.fontHeight / 2), 16777215);
public void render(MatrixStack matrices, int i, int j, int k, int l, int m, int n, int o, boolean bl, float f) {
Drawer.drawCenteredString(matrices, this.font, this.title, this.width / 2, j + (this.height / 2) - (this.font.fontHeight / 2), 16777215);
}

public List<? extends Element> children() {
Expand Down
73 changes: 26 additions & 47 deletions src/main/java/net/entityoutliner/EntityOutliner.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,47 @@
import org.lwjgl.glfw.GLFW;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.keybinding.FabricKeyBinding;
import net.fabricmc.fabric.api.client.keybinding.KeyBindingRegistry;
import net.fabricmc.fabric.api.event.client.ClientTickCallback;
import net.minecraft.util.Identifier;
import net.minecraft.client.MinecraftClient;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.text.TranslatableText;

public class EntityOutliner implements ClientModInitializer {

private FabricKeyBinding configBind;
private FabricKeyBinding outlineBind;

private boolean prevPressed;
public static boolean outliningEntities;

private static KeyBinding configBind;
private static KeyBinding outlineBind;

@Override
public void onInitializeClient() {
setupKeybinds();
}

private void setupKeybinds() {
KeyBindingRegistry.INSTANCE.addCategory("Entity Outliner");

// Uses fabric's keybinding system to add the binds
configBind = FabricKeyBinding.Builder.create(
new Identifier("entity-outliner", "selector"),
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_P,
"Entity Outliner"
).build();

outlineBind = FabricKeyBinding.Builder.create(
new Identifier("entity-outliner", "outline"),
InputUtil.Type.KEYSYM,
GLFW.GLFW_KEY_O,
"Entity Outliner"
).build();
configBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.entity-outliner.selector", // Keybind name
InputUtil.Type.KEYSYM, // Keybind type
GLFW.GLFW_KEY_P, // Keycode
"title.entity-outliner.title" // Keybind category
));

outlineBind = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.entity-outliner.outline", // Keybind name
InputUtil.Type.KEYSYM, // Keybind type
GLFW.GLFW_KEY_O, // Keycode
"title.entity-outliner.title" // Keybind category
));

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (outlineBind.wasPressed()) {
outliningEntities = !outliningEntities;
}
});

KeyBindingRegistry.INSTANCE.register(configBind);
KeyBindingRegistry.INSTANCE.register(outlineBind);

// Register callback that opens entity selector
ClientTickCallback.EVENT.register(e -> {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (configBind.isPressed()) {
MinecraftClient client = MinecraftClient.getInstance();
if (client != null) {
client.openScreen(new EntitySelector(new TranslatableText("title.entity-outliner.selector")));
}
}
});

// Register callback that toggles entity outlining
ClientTickCallback.EVENT.register(e -> {
if (outlineBind.isPressed()) {
if (!prevPressed) {
outliningEntities = !outliningEntities;
prevPressed = true;
}
} else {
prevPressed = false;
} // The ClientTickCallback is called every tick, so this logic prevents rapid toggling when key is held >1 tick
});
}
}
Loading

0 comments on commit bb35fea

Please sign in to comment.