Fix inward & downward animation types and Gradle stuff

This commit is contained in:
flogic 2020-10-24 21:42:46 -06:00
parent c97e03e3c0
commit 180e5ead1a
No known key found for this signature in database
GPG Key ID: AD25E4DF29DECD31
3 changed files with 43 additions and 39 deletions

View File

@ -1,5 +1,6 @@
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'io.freefair.lombok' version '5.2.1'
id 'maven-publish'
}
@ -14,10 +15,11 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API.
// Make a collection of all api modules we wish to use
//TODO try this approach to fabric api in the future to avoid unneeded modules.
// for some reason it asks for like fabric-biomes and stuff right now.
// Set<String> apiModules = [
// "fabric-api-base"
//// "fabric-tool-attribute-api-v1"
// "fabric-api-base",
// "fabric-registry-sync-v0"
// ]
//
// // Add each module as a dependency
@ -25,26 +27,21 @@ dependencies {
// modImplementation(fabricApi.module(it, project.fabric_version))
// }
// Fabric API.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Cloth Config / Autoconfig
modImplementation("me.shedaniel.cloth:config-2:4.8.2") {
exclude(group: "net.fabricmc.fabric-api")
exclude module: "modmenu"
exclude(module: "modmenu")
}
modImplementation("me.sargunvohra.mcmods:autoconfig1u:3.2.2") {
exclude(group: "net.fabricmc.fabric-api")
}
include "me.shedaniel.cloth:config-2:4.8.2"
include "me.sargunvohra.mcmods:autoconfig1u:3.2.2"
include("me.shedaniel.cloth:config-2:4.8.2")
include("me.sargunvohra.mcmods:autoconfig1u:3.2.2")
modImplementation "io.github.prospector:modmenu:1.14.6+build.31"
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
modImplementation("io.github.prospector:modmenu:1.14.6+build.31")
}
minecraft {
@ -81,22 +78,4 @@ jar {
}
// configure the maven publication
publishing {
// publications {
// mavenJava(MavenPublication) {
// // add all the jars that should be included when publishing to maven
// artifact(remapJar) {
// builtBy remapJar
// }
// artifact(sourcesJar) {
// builtBy remapSourcesJar
// }
// }
// }
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
//publishing {}

2
lombok.config Normal file
View File

@ -0,0 +1,2 @@
# This file is generated by the 'io.freefair.lombok' Gradle plugin
config.stopBubbling = true

View File

@ -1,6 +1,7 @@
package cc.flogi.dev.smoothchunks.client.handler;
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
import cc.flogi.dev.smoothchunks.client.config.LoadAnimation;
import cc.flogi.dev.smoothchunks.client.config.SmoothChunksConfig;
import cc.flogi.dev.smoothchunks.util.UtilEasing;
import lombok.AllArgsConstructor;
@ -9,6 +10,8 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import java.util.WeakHashMap;
@ -24,14 +27,30 @@ public final class ChunkAnimationHandler {
public static ChunkAnimationHandler get() {return instance;}
public void addChunk(ChunkBuilder.BuiltChunk chunk) {
animations.put(chunk, new AnimationController(chunk.getOrigin(), System.currentTimeMillis()));
Direction direction = null;
if (SmoothChunksClient.get().getConfig().getLoadAnimation() == LoadAnimation.INWARD
&& MinecraftClient.getInstance().getCameraEntity() != null) {
BlockPos dif = chunk.getOrigin().subtract(MinecraftClient.getInstance().getCameraEntity().getBlockPos());
int difX = Math.abs(dif.getX());
int difZ = Math.abs(dif.getZ());
if (difX > difZ) {
if (dif.getX() > 0) direction = Direction.WEST;
else direction = Direction.EAST;
} else {
if (dif.getZ() > 0) direction = Direction.NORTH;
else direction = Direction.SOUTH;
}
}
animations.put(chunk, new AnimationController(chunk.getOrigin(), direction, System.currentTimeMillis()));
}
public void updateChunk(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
SmoothChunksConfig config = SmoothChunksClient.get().getConfig();
// System.out.println(config.getDuration() + " - " + config.getLoadAnimation().name() + " - " + config.isDisableNearby());
AnimationController controller = animations.get(chunk);
if (controller == null || MinecraftClient.getInstance().getCameraEntity() == null) return;
@ -45,18 +64,21 @@ public final class ChunkAnimationHandler {
double completion = (double) (System.currentTimeMillis() - controller.getStartTime()) / config.getDuration() / 1000d;
completion = UtilEasing.easeOutSine(Math.min(completion, 1.0));
int chunkY = controller.getFinalPos().getY();
BlockPos finalPos = controller.getFinalPos();
switch (config.getLoadAnimation()) {
default:
case DOWNWARD:
stack.translate(0, 256 - chunkY - (completion * chunkY), 0);
stack.translate(0, finalPos.getY() - (completion * finalPos.getY()), 0);
break;
case UPWARD:
stack.translate(0, -chunkY + (completion * chunkY), 0);
stack.translate(0, -finalPos.getY() + (completion * finalPos.getY()), 0);
break;
case INWARD:
stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
if (controller.getDirection() == null) break;
Vec3i dirVec = controller.getDirection().getVector();
double mod = -(200 - UtilEasing.easeInOutSine(completion) * 200);
stack.translate(dirVec.getX() * mod, 0, dirVec.getZ() * mod);
break;
case SCALE:
stack.scale((float) completion, (float) completion, (float) completion);
@ -69,6 +91,7 @@ public final class ChunkAnimationHandler {
@AllArgsConstructor @Data
private static class AnimationController {
private BlockPos finalPos;
private Direction direction;
private long startTime;
}
}