Skip to content

Commit

Permalink
Updated to 1.17
Browse files Browse the repository at this point in the history
Fixed incorrect issues URL.
  • Loading branch information
TurtleArmyMc committed Jun 10, 2021
1 parent dc6daa8 commit 7277e37
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 62 deletions.
25 changes: 12 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '0.6-SNAPSHOT'
id 'fabric-loom' version '0.8-SNAPSHOT'
id 'maven-publish'
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

archivesBaseName = project.archives_base_name
version = project.mod_version + "+mc" + project.minecraft_version
Expand All @@ -16,7 +16,8 @@ minecraft {
dependencies {
repositories {
maven {
url = "https://maven.fabricmc.net/io/github/prospector/modmenu/"
name = 'Terraformers'
url = 'https://maven.terraformersmc.com/releases/'
}
}

Expand All @@ -25,27 +26,25 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"

modCompileOnly "io.github.prospector:modmenu:${project.modmenu_version}"
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}") {
transitive = false
}
}

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 {
it.options.encoding = "UTF-8"
it.options.release = 16
}

// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.16.5
yarn_mappings = 1.16.5+build.4
loader_version = 0.11.1
minecraft_version = 1.17
yarn_mappings = 1.17+build.5
loader_version = 0.11.3

#Mod properties
mod_version = 1.0.0
mod_version = 1.0.1
maven_group = com.turtlearmymc.panoramatweaker
archives_base_name = panorama_tweaker

#Dependencies
modmenu_version = 1.14.9+build.14
modmenu_version = 2.0.0-beta.7
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-7.0.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
80 changes: 45 additions & 35 deletions src/main/java/com/turtlearmymc/panoramatweaker/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.AbstractParentElement;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.RotatingCubeMapRenderer;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.util.math.MatrixStack;
Expand All @@ -40,12 +39,12 @@ protected ConfigScreen(Screen parent) {
protected void init() {
final int y_padding = 28;

this.addButton(new ButtonWidget(this.width / 2 - 154, this.height - y_padding, 150, 20,
this.addDrawableChild(new ButtonWidget(this.width / 2 - 154, this.height - y_padding, 150, 20,
new TranslatableText("gui.cancel"), (button) -> {
this.restoreConfig();
client.openScreen(parent);
}));
this.addButton(new ButtonWidget(this.width / 2 + 4, this.height - y_padding, 150, 20,
this.addDrawableChild(new ButtonWidget(this.width / 2 + 4, this.height - y_padding, 150, 20,
new TranslatableText("gui.done"), (button) -> {
this.saveConfig();
client.openScreen(parent);
Expand All @@ -57,44 +56,57 @@ protected void init() {
int x = (this.width / 2) - 154;
int y = ((this.height - widgetPadding) * 0) / widgetCount + y_padding;

this.children
.addAll((new OptionWidget(this.textRenderer, new TranslatableText("panorama_tweaker.rotationSpeed"), x,
y, 308, 20, Config.DEFAULT_ROTATION_SPEED, PanoramaTweaker.config.rotationSpeed, -10, 10,
val -> PanoramaTweaker.config.rotationSpeed = val)).children());
for (ClickableWidget child : (new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.rotationSpeed"), x, y, 308, 20, Config.DEFAULT_ROTATION_SPEED,
PanoramaTweaker.config.rotationSpeed, -10, 10, val -> PanoramaTweaker.config.rotationSpeed = val))
.children()) {
this.addDrawableChild(child);
}

y = ((this.height - widgetPadding) * 1) / widgetCount + y_padding;
this.children.addAll((new OptionWidget(this.textRenderer,
for (ClickableWidget child : ((new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.startingHorizontalAngle"), x, y, 308, 20,
Config.DEFAULT_STARTING_HORIZONTAL_ANGLE, PanoramaTweaker.config.startingHorizontalAngle, -180, 180,
val -> PanoramaTweaker.config.startingHorizontalAngle = val)).children());
val -> PanoramaTweaker.config.startingHorizontalAngle = val)).children())) {
this.addDrawableChild(child);
}

y = ((this.height - widgetPadding) * 2) / widgetCount + y_padding;
this.children
.addAll((new OptionWidget(this.textRenderer, new TranslatableText("panorama_tweaker.verticalAngle"), x,
y, 308, 20, Config.DEFAULT_VERTICAL_ANGLE, PanoramaTweaker.config.verticalAngle, -90, 90,
val -> PanoramaTweaker.config.verticalAngle = val)).children());
for (ClickableWidget child : ((new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.verticalAngle"), x, y, 308, 20, Config.DEFAULT_VERTICAL_ANGLE,
PanoramaTweaker.config.verticalAngle, -90, 90, val -> PanoramaTweaker.config.verticalAngle = val))
.children())) {
this.addDrawableChild(child);
}

y = ((this.height - widgetPadding) * 3) / widgetCount + y_padding;
this.children.addAll((new OptionWidget(this.textRenderer, new TranslatableText("panorama_tweaker.swayAngle"), x,
y, 308, 20, Config.DEFAULT_SWAY_ANGLE, PanoramaTweaker.config.swayAngle, -90, 90,
val -> PanoramaTweaker.config.swayAngle = val)).children());
for (ClickableWidget child : ((new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.swayAngle"), x, y, 308, 20, Config.DEFAULT_SWAY_ANGLE,
PanoramaTweaker.config.swayAngle, -90, 90, val -> PanoramaTweaker.config.swayAngle = val))
.children())) {
this.addDrawableChild(child);
}

y = ((this.height - widgetPadding) * 4) / widgetCount + y_padding;
this.children.addAll((new OptionWidget(this.textRenderer, new TranslatableText("panorama_tweaker.swaySpeed"), x,
y, 308, 20, Config.DEFAULT_SWAY_SPEED, PanoramaTweaker.config.swaySpeed, 0, 10,
val -> PanoramaTweaker.config.swaySpeed = val)).children());
for (ClickableWidget child : ((new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.swaySpeed"), x, y, 308, 20, Config.DEFAULT_SWAY_SPEED,
PanoramaTweaker.config.swaySpeed, 0, 10, val -> PanoramaTweaker.config.swaySpeed = val)).children())) {
this.addDrawableChild(child);
}

y = ((this.height - widgetPadding) * 5) / widgetCount + y_padding;
this.children.addAll(
(new OptionWidget(this.textRenderer, new TranslatableText("panorama_tweaker.initialSwayProgress"), x, y,
308, 20, Config.DEFAULT_INITIAL_SWAY_PROGRESS, PanoramaTweaker.config.initialSwayProgress, -1,
1, val -> PanoramaTweaker.config.initialSwayProgress = val)).children());
for (ClickableWidget child : ((new OptionWidget(this.textRenderer,
new TranslatableText("panorama_tweaker.initialSwayProgress"), x, y, 308, 20,
Config.DEFAULT_INITIAL_SWAY_PROGRESS, PanoramaTweaker.config.initialSwayProgress, -1, 1,
val -> PanoramaTweaker.config.initialSwayProgress = val)).children())) {
this.addDrawableChild(child);
}
}

@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
this.backgroundRenderer.render(delta, MathHelper.clamp(1, 0.0F, 1.0F));
for (Element child : this.children) {
for (Element child : this.children()) {
if (child instanceof Drawable) {
((Drawable) child).render(matrices, mouseX, mouseY, delta);
}
Expand All @@ -103,10 +115,10 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
for (Element child : this.children) {
if (child instanceof AbstractButtonWidget) {
if (((AbstractButtonWidget) child).isFocused()) {
((AbstractButtonWidget) child).changeFocus(false);
for (Element child : this.children()) {
if (child instanceof ClickableWidget) {
if (((ClickableWidget) child).isFocused()) {
((ClickableWidget) child).changeFocus(false);
}
}
}
Expand All @@ -121,10 +133,10 @@ protected void saveConfig() {
PanoramaTweaker.config.save();
}

protected class OptionWidget extends AbstractParentElement {
protected class OptionWidget {
private final double defaultVal;

private final List<AbstractButtonWidget> children;
private final List<ClickableWidget> children;
private final OptionSlider slider;
private final TextFieldWidget textField;
private final ButtonWidget resetButton;
Expand Down Expand Up @@ -158,12 +170,11 @@ public OptionWidget(TextRenderer font, TranslatableText text, int x, int y, int
this.textField.setUneditableColor(0xFF0000);
}
});
this.setFocused(this.textField);
this.resetButton = new ButtonWidget(x + width - 50, y, 50, height, new TranslatableText("controls.reset"),
(buttonWidget) -> {
this.resetToDefault();
});
this.children = new ArrayList<AbstractButtonWidget>();
this.children = new ArrayList<ClickableWidget>();
this.children.add(this.slider);
this.children.add(this.textField);
this.children.add(this.resetButton);
Expand Down Expand Up @@ -193,8 +204,7 @@ protected boolean isDefault() {
return this.value == this.defaultVal;
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.turtlearmymc.panoramatweaker;

import java.util.function.Function;

import io.github.prospector.modmenu.api.ModMenuApi;
import net.minecraft.client.gui.screen.Screen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;

public class ModMenuApiImpl implements ModMenuApi {
@Override
public Function<Screen, ? extends Screen> getConfigScreenFactory() {
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return ConfigScreen::new;
}
}
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"contact": {
"homepage": "https://www.curseforge.com/minecraft/mc-mods/panorama-tweaker",
"sources": "https://github.com/TurtleArmyMc/Panorama-Tweaker",
"issues": "https://github.com/shedaniel/Panorama-Tweaker/issues"
"issues": "https://github.com/TurtleArmyMc/Panorama-Tweaker/issues"
},
"license": "LGPL-3.0",
"icon": "assets/panorama_tweaker/icon.png",
Expand All @@ -30,6 +30,9 @@
"depends": {
"fabricloader": ">=0.11.1"
},
"recommends": {
"modmenu": ">=2.0.0-beta7"
},
"custom": {
"modmenu:clientsideOnly": true
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/panorama_tweaker.mixins.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"required": true,
"package": "com.turtlearmymc.panoramatweaker.mixin",
"compatibilityLevel": "JAVA_8",
"compatibilityLevel": "JAVA_16",
"mixins": [],
"client": [
"RotatingCubeMapRendererMixin"
Expand Down

0 comments on commit 7277e37

Please sign in to comment.