Skip to content

Commit

Permalink
Messy 1.20.4, needs to be cleaned and tested
Browse files Browse the repository at this point in the history
  • Loading branch information
brentmaas committed Jan 12, 2024
1 parent dcd4d35 commit f508b49
Show file tree
Hide file tree
Showing 60 changed files with 2,028 additions and 81 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ configure(subprojects.findAll {it.name != 'common'}) {
dependencies {
implementation project(":common")
}
sourceSets.main {
java {
if(it.name != 'forge1.20.4') { //TODO: Make this work universally again
sourceSets.main.java {
srcDir '../common/src'
}
resources {
srcDir '../common/resources'
}
}
sourceSets.main.resources {
srcDir '../common/resources'
}
eclipse {
classpath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.LiteralText;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, new LiteralText(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.LiteralText;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, new LiteralText(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.LiteralText;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, new LiteralText(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.Text;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, Text.literal(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.Text;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, Text.literal(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.Text;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, Text.literal(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import net.minecraft.text.Text;

public class CheckboxRunnableButtonImpl extends CheckboxWidget implements ICheckboxRunnableButton {
protected ICheckboxRunnableButton.IPressable onPress;
protected final ICheckboxRunnableButton.IPressable onPress;

public CheckboxRunnableButtonImpl(int x, int y, int width, int height, String title, boolean checked, boolean drawTitle, ICheckboxRunnableButton.IPressable onPress) {
super(x, y, width, height, Text.literal(title), checked, drawTitle);
Expand All @@ -25,10 +25,6 @@ public boolean isCheckboxSelected() {
return isChecked();
}

public void setVisible(boolean visible) {
this.visible = visible;
}

public void setActive(boolean active) {
this.active = active;
}
Expand Down
33 changes: 33 additions & 0 deletions fabric1.20.4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# gradle

.gradle/
build/
out/
classes/

# eclipse

*.launch

# idea

.idea/
*.iml
*.ipr
*.iws

# vscode

.settings/
.vscode/
bin/
.classpath
.project

# macos

*.DS_Store

# fabric

run/
85 changes: 85 additions & 0 deletions fabric1.20.4/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
plugins {
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = gradle.ext.fabricname
version = gradle.ext.modversion
group = gradle.ext.fabricgroup

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}

loom {
runs {
client {
runDir = "../run"
}
}
}

dependencies {
// 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}"

// 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.

// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}

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

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

tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
}

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") {
rename { "${it}_${project.archivesBaseName}"}
}
}

// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}

// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
11 changes: 11 additions & 0 deletions fabric1.20.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G

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

# Dependencies
fabric_version=0.91.3+1.20.4
10 changes: 10 additions & 0 deletions fabric1.20.4/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package brentmaas.buildguide.fabric;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import brentmaas.buildguide.common.BuildGuide;
import brentmaas.buildguide.fabric.screen.ScreenHandler;
import brentmaas.buildguide.fabric.screen.widget.WidgetHandler;
import brentmaas.buildguide.fabric.shape.ShapeHandler;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;

public class BuildGuideFabric implements ClientModInitializer {
private static final Logger logger = LogManager.getLogger();

public void onInitializeClient() {
BuildGuide.register(new InputHandler(), new ScreenHandler(), new WidgetHandler(), new StateManager(), new ShapeHandler(), new RenderHandler(), new LogHandler(logger), FabricLoader.getInstance().getConfigDir().toString() + "/");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package brentmaas.buildguide.fabric;

import brentmaas.buildguide.common.AbstractInputHandler;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;

public class InputHandler extends AbstractInputHandler {
public IKeyBind registerKeyBind(String name, int keyCode) {
return new KeyBindImpl(name, keyCode);
}

public void registerOnKeyInput() {
ClientTickEvents.END_CLIENT_TICK.register(this::onKeyInputProxy);
}

public void onKeyInputProxy(MinecraftClient client) {
onKeyInput();
}

public class KeyBindImpl implements IKeyBind {
private KeyBinding bind;

public KeyBindImpl(String name, int keyCode) {
bind = KeyBindingHelper.registerKeyBinding(new KeyBinding(name, InputUtil.Type.KEYSYM, keyCode, category));
}

public boolean isDown() {
return bind.wasPressed();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package brentmaas.buildguide.fabric;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.spi.StandardLevel;

import brentmaas.buildguide.common.ILogHandler;

public class LogHandler implements ILogHandler {
private Logger logger;

public LogHandler(Logger logger) {
this.logger = logger;
}

public void fatal(String message) {
logger.fatal(message);
}

public void error(String message) {
logger.error(message);
}

public void errorOrHigher(String message) {
logger.log(logger.getLevel().intLevel() >= StandardLevel.ERROR.intLevel() ? Level.ERROR : logger.getLevel(), message);
}

public void debugOrHigher(String message) {
logger.log(logger.getLevel().intLevel() >= StandardLevel.DEBUG.intLevel() ? Level.DEBUG : logger.getLevel(), message);
}

public void debugThrowable(String message, Throwable throwable) {
logger.debug(message, throwable);
}
}
Loading

0 comments on commit f508b49

Please sign in to comment.