Merge branch 'release/1.0.0' into main

This commit is contained in:
flogic 2020-11-03 17:46:49 -07:00
commit f6928604a0
No known key found for this signature in database
GPG Key ID: AD25E4DF29DECD31
36 changed files with 423 additions and 116 deletions

3
.github/FUNDING.YML vendored Normal file
View File

@ -0,0 +1,3 @@
# These are supported funding model platforms
custom: [ 'https://paypal.me/caden2k3' ]

33
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,33 @@
---
name: Bug report
about: Use this template if you're running into bugs or other issues
title: ''
labels: bug
assignees: ''
---
### Expected Behavior
Replace this text with what you expected to happen.
_Example: The Piston should extend._
### Actual Behavior
Replace this text with what actually happened.
_Example: The Piston does not extend._
### Reproduction Steps
Provide information on how to reproduce this game crash. You can either fill in the example below or do something else -- just make sure your instructions are minimal and clear! If applicable, please provide a world file as a compressed ZIP which contains a minimally reproducible example of the issue.
1. Place a Redstone Lamp beside a Redstone Repeater
2. Use a Lever to activate the Redstone Repeater
3. Nothing happens
### Attachments
Add any relevant screenshots or videos to this issue as you feel necessary to explain the issue.
### System Information
You can obtain this information from the in-game debug screen or through using [DxDiag](https://support.microsoft.com/en-us/help/4028644/windows-open-and-run-dxdiagexe) on Windows.
- Java Version: [fill me in]
- CPU: [fill me in]
- GPU: [fill me in]

21
.github/ISSUE_TEMPLATE/crash-report.md vendored Normal file
View File

@ -0,0 +1,21 @@
---
name: Crash report
about: Use this template if your game is crashing or failing to start correctly
title: ''
labels: crash
assignees: ''
---
### Reproduction Steps
Provide information on how to reproduce this game crash. This step is critical for ensuring that your crash can be debugged by other developers. You can either fill in the example below or do something else -- just make sure your instructions are minimal and clear. If applicable, provide a Minecraft save containing a minimal example on how to reproduce this crash as a compressed ZIP file.
1. Place a Redstone Lamp beside a Redstone Repeater
2. Use a Lever to activate the Redstone Repeater
3. The game crashes
### Crash Report File
Please upload your crash report as a file to [GitHub Gist](https://gist.github.com/) and replace this text with a link to the uploaded report.
### Additional Information
Provide any additional information or context which may be relevant to the issue. If you have none to add, you can remove this section.

View File

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,26 @@
---
name: Bug fix
about: Use this template if you're creating a pull request which fixes another bug or issue
title: ''
labels: bug
assignees: ''
---
### Preface
Please read our [Contributor Guidelines](https://github.com/fl0gic/smooth-chunks/blob/main/contributing.md) before
submitting any pull requests to this repository.
By submitting a pull request, you are indicating that you agree to the [Contributor License Agreement](https://github.com/fl0gic/smooth-chunks/blob/main/contributing.md#contributor-license-agreement-cla)
and that your code will be licensed irrecoverably under the GNU LGPLv3. If you do not agree to these terms, do not open
a pull request.
Please remove this section before submitting your pull request. Doing so indicates that you have read and acknowledged it.
### Linked Issues
Provide links to the issue(s) which will be closed upon merging this pull request. There must be an open issue for
pull requests which fix bugs or other issues.
### Proposed Changes
Provide a detailed description of what your pull request changes.

View File

@ -0,0 +1,22 @@
---
name: Bug fix
about: Use this template if you're creating a pull request which adds a feature or other enhancement
title: ''
labels: enhancement
assignees: ''
---
### Preface
Please read our [Contributor Guidelines](https://github.com/jellysquid3/sodium-fabric/blob/1.15.x/CONTRIBUTING.md) before
submitting any pull requests to this repository.
By submitting a pull request, you are indicating that you agree to the [Contributor License Agreement](https://github.com/jellysquid3/sodium-fabric/blob/1.15.x/CONTRIBUTING.md#contributor-license-agreement-cla)
and that your code will be licensed irrecoverably under the GNU LGPLv3. If you do not agree to these terms, do not open
a pull request.
Please remove this section before submitting your pull request. Doing so indicates that you have read and acknowledged it.
### Proposed Changes
Provide a detailed description of what your pull request changes.

View File

@ -3,7 +3,7 @@
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
name: "codeql-analysis"
on:
push:

View File

@ -1,4 +1,4 @@
name: Java CI with Gradle
name: "gradle-build"
on: [ push, pull_request ]

View File

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2020 flogic
Copyright (c) 2020 Caden Kriese
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,13 +1,9 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'fabric-loom' version '0.5-SNAPSHOT'
id 'io.freefair.lombok' version '5.2.1'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name
version = project.mod_version as Object
group = project.maven_group as Object
@ -18,27 +14,34 @@ dependencies {
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API.
//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-registry-sync-v0"
// ]
//
// // Add each module as a dependency
// apiModules.forEach {
// modImplementation(fabricApi.module(it, project.fabric_version))
// }
// Fabric API.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Cloth Config / Autoconfig
modApi("me.shedaniel.cloth:config-2:4.8.2") {
modImplementation("me.shedaniel.cloth:config-2:${project.cloth_version}") {
exclude(group: "net.fabricmc.fabric-api")
exclude module: "modmenu"
exclude(module: "modmenu")
}
modApi("me.sargunvohra.mcmods:autoconfig1u:3.2.2") {
modImplementation("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}") {
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:${project.cloth_version}")
include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}")
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:${project.modmenu_version}")
}
minecraft {
@ -50,7 +53,6 @@ processResources {
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
// filter(ReplaceTokens, tokens: [version: project.version])
expand "version": project.version
}
@ -76,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 {}

42
contributing.md Normal file
View File

@ -0,0 +1,42 @@
## Issues
When opening issues, please be sure to include the following information as applicable.
- The exact version of the mod you are running, such as `0.1.0-fabric`, and the version of Fabric/Forge you are using.
- If your issue is a crash, attach the latest client or server log, and the complete crash report as a file. You can
attach these as a file (preferred) or host them on a service such as [GitHub Gist](https://gist.github.com/) or [Hastebin](https://hastebin.com/).
- If your issue is a bug or otherwise unexpected behavior, explain what you expected to happen.
- If your issue only occurs with other mods installed, be sure to specify the names and versions of those mods.
## Pull Requests
It's super awesome to hear you're wishing to contribute to the project! Before you open a pull request, you'll need to
give a quick read to the following guidelines.
### Contributor License Agreement (CLA)
By submitting changes to this repository, you are hereby agreeing that:
- Your contributions will be licensed irrecoverably under the [MIT License](https://mit-license.org).
- Your contributions are of your own work and free of legal restrictions (such as patents and copyrights) or other
issues which would pose issues for inclusion or distribution under the above license.
If you do not agree to these terms, please do not submit contributions to this repository.
### Code Style
When contributing source code changes to the project, ensure that you make consistent use of the code style guidelines
used throughout the codebase (which follow pretty closely after the standard Java code style guidelines). These guidelines
have also been packaged as EditorConfig and IDEA inspection profiles which can be found in the repository root and `idea`
directory respectively.
- Use 4 spaces for indentation, not tabs. Avoid lines which exceed 120 characters.
- Use `this` to qualify member and field access.
- Always use braces when writing if-statements and loops.
- Annotate overriding methods with `@Override` so that breaking changes when updating will create hard compile errors.
### Making a Pull Request
Your pull request should include a brief description of the changes it makes and link to any open issues which it
resolves. You should also ensure that your code is well documented where non-trivial and that it follows the
outlined code style guidelines above.

View File

@ -1,14 +1,16 @@
# Check for updates on https://modmuss50.me/fabric.html
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.16.3
yarn_mappings=1.16.3+build.17
loader_version=0.10.0+build.208
minecraft_version=1.16.4
yarn_mappings=1.16.4+build.1
loader_version=0.10.6+build.214
# Mod Properties
mod_version=0.1.0-SNAPSHOT
mod_version=1.0.0
maven_group=cc.flogi.dev
archives_base_name=smooth-chunks
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.22.0+build.408-1.16
fabric_version=0.25.1+build.416-1.16
autoconfig_version=3.3.1
cloth_version=4.8.2
modmenu_version=1.14.6+build.31

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -130,7 +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

21
gradlew.bat vendored
View File

@ -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.
@ -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%
@ -64,21 +64,6 @@ 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
@ -86,7 +71,7 @@ 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

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

BIN
media/banner.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 387 KiB

BIN
media/icon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 KiB

View File

@ -1,5 +1,33 @@
![Smooth Chunks Logo](src/main/resources/assets/smooth-chunks/icon.png)
<p align="center">
<a href="https://github.com/fl0gic/smooth-chunks/blob/master/LICENSE"><img src="https://img.shields.io/github/license/fl0gic/smooth-chunks?style=for-the-badge"></a>
<img src="https://img.shields.io/github/v/tag/fl0gic/smooth-chunks?include_prereleases&label=version&style=for-the-badge">
<img src="https://img.shields.io/github/workflow/status/fl0gic/smooth-chunks/gradle-build?style=for-the-badge">
<img src="https://cf.way2muchnoise.eu/full_smooth-chunks_downloads.svg?badge_style=for_the_badge">
<img src="https://cf.way2muchnoise.eu/versions/smooth-chunks_latest.svg?badge_style=for_the_badge">
<a href="https://fabricmc.net"><img src="https://img.shields.io/badge/modloader-fabric-blue?style=for-the-badge"></a>
</p>
<p align="center">
<img width="384" height="384" src="https://github.com/fl0gic/smooth-chunks/blob/543cb55c7fa0397a437260254b0a74dde2ebc6a0/src/main/resources/assets/smooth-chunks/icon.png?raw=true">
</p>
<h1 align="center">Smooth Chunks</h1>
<p align="center">Chunk loading in Minecraft can be very jagged when they appear out of nowhere. With this mod, you can configure a nice animation for how chunks load in to your world.</p>
# Smooth Chunks
## Animations
### Upward
![Gif of upward loading](media/showcase-gifs/upward.gif)
### Downward
![Gif of upward loading](media/showcase-gifs/downward.gif)
### Inward
![Gif of upward loading](media/showcase-gifs/inward.gif)
### Scale
![Gif of upward loading](media/showcase-gifs/scale.gif)
## Incompatibilities
Unfortunately the mod is incompatible with Sodium and OptiFine/OptiFabric at this time. I'd like to add support for them eventually though. I also assume that the mod is incompatible with many other rendering focused mods such as Canvas, though I haven't tested it.

View File

@ -1,7 +1,6 @@
package cc.flogi.dev.smoothchunks.client;
import cc.flogi.dev.smoothchunks.client.config.SmoothChunksConfig;
import cc.flogi.dev.smoothchunks.client.handler.ChunkAnimationHandler;
import lombok.Getter;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.Toml4jConfigSerializer;
@ -16,17 +15,14 @@ import net.fabricmc.api.Environment;
*/
@Environment(EnvType.CLIENT) public class SmoothChunksClient implements ClientModInitializer {
private static SmoothChunksClient instance;
public static SmoothChunksClient get() {return instance;}
@Getter private SmoothChunksConfig config;
@Getter private ChunkAnimationHandler chunkAnimationHandler;
public static SmoothChunksClient get() {return instance;}
@Override public void onInitializeClient() {
instance = this;
AutoConfig.register(SmoothChunksConfig.class, Toml4jConfigSerializer::new);
config = AutoConfig.getConfigHolder(SmoothChunksConfig.class).getConfig();
chunkAnimationHandler = new ChunkAnimationHandler(config);
}
}

View File

@ -9,5 +9,5 @@ public enum LoadAnimation {
DOWNWARD,
UPWARD,
INWARD,
FADE
SCALE
}

View File

@ -13,14 +13,31 @@ import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
*/
@Config(name = "smooth-chunks") @Config.Gui.Background("minecraft:textures/block/stone.png") @Getter
public class SmoothChunksConfig implements ConfigData {
//TODO use localization for comment strings. (Somehow, not super straightforward bc annotations need const value)
@Comment("Duration of the animation in seconds.")
@ConfigEntry.BoundedDiscrete(min = 0, max=10)
int duration = 1;
double duration = 1;
@Comment("The amount the chunk moves to get to its final position.")
@ConfigEntry.BoundedDiscrete(min = 1, max = 10)
int translationAmount = 5;
@Comment("Type of animation for loading chunks.")
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
LoadAnimation loadAnimation = LoadAnimation.DOWNWARD;
LoadAnimation loadAnimation = LoadAnimation.UPWARD;
@Comment("Disable animating chunks close to you")
boolean disableNearby = false;
boolean disableNearby = true;
/*
* Custom Getters
*/
/**
* Gets the config value for translation amount, translating config value to usable value.
*
* @return The translation amount as an int 1 to 10 where higher = more translation.
*/
public double getTranslationAmount() {
return (double) translationAmount / 5d;
}
}

View File

@ -1,16 +1,23 @@
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;
import lombok.Data;
import lombok.Getter;
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.ArrayList;
import java.util.List;
import java.util.WeakHashMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @author Caden Kriese (flogic)
@ -18,54 +25,88 @@ import java.util.WeakHashMap;
* Created on 09/27/2020
*/
public final class ChunkAnimationHandler {
private final long DURATION;
private final LoadAnimation LOAD_ANIMATION;
private final boolean DISABLE_NEARBY;
/*TODO use Reference2ReferenceLinkedHashMap from FastUtil or just inject the AnimationController directly into BuiltChunk.
* Need to solve concurrency issue as currently #addChunk is called from both render & worker threads.
*/
private final WeakHashMap<ChunkBuilder.BuiltChunk, AnimationController> animations = new WeakHashMap<>();
private final List<BlockPos> completedChunks = new ArrayList<>();
private static final ChunkAnimationHandler instance = new ChunkAnimationHandler();
private final Map<ChunkBuilder.BuiltChunk, AnimationController> animations = new HashMap<>();
@Getter private final Set<Vec3i> loadedChunks = new HashSet<>();
public ChunkAnimationHandler(SmoothChunksConfig config) {
DURATION = config.getDuration() * 1000;
LOAD_ANIMATION = config.getLoadAnimation();
DISABLE_NEARBY = config.isDisableNearby();
public static ChunkAnimationHandler get() {
return instance;
}
public void update(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
if (completedChunks.contains(chunk.getOrigin())) return;
public void addChunk(ChunkBuilder.BuiltChunk chunk) {
Vec3i origin = chunk.getOrigin();
if (loadedChunks.contains(origin)) return;
loadedChunks.add(origin);
Direction direction = null;
if (SmoothChunksClient.get().getConfig().getLoadAnimation() == LoadAnimation.INWARD
&& MinecraftClient.getInstance().getCameraEntity() != null) {
BlockPos delta = chunk.getOrigin().subtract(MinecraftClient.getInstance().getCameraEntity().getBlockPos());
int dX = Math.abs(delta.getX());
int dZ = Math.abs(delta.getZ());
if (dX > dZ) {
if (delta.getX() > 0) direction = Direction.WEST;
else direction = Direction.EAST;
} else {
if (delta.getZ() > 0) direction = Direction.NORTH;
else direction = Direction.SOUTH;
}
}
animations.putIfAbsent(chunk, new AnimationController(chunk.getOrigin(), direction, System.currentTimeMillis()));
}
public void updateChunk(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
SmoothChunksConfig config = SmoothChunksClient.get().getConfig();
AnimationController controller = animations.get(chunk);
if (controller == null || MinecraftClient.getInstance().getCameraEntity() == null) return;
if (controller == null) {
controller = new AnimationController(chunk.getOrigin(), System.currentTimeMillis());
animations.put(chunk, controller);
BlockPos finalPos = controller.getFinalPos();
if (config.isDisableNearby()) {
double dX = finalPos.getX() - MinecraftClient.getInstance().getCameraEntity().getPos().getX();
double dZ = finalPos.getZ() - MinecraftClient.getInstance().getCameraEntity().getPos().getZ();
if (dX * dX + dZ * dZ < 32 * 32) return;
}
double completion = (double) (System.currentTimeMillis() - controller.getStartTime()) / DURATION;
completion = Math.min(completion, 1.0);
double completion = (double) (System.currentTimeMillis() - controller.getStartTime()) / config.getDuration() / 1000d;
completion = UtilEasing.easeOutSine(Math.min(completion, 1.0));
switch (LOAD_ANIMATION) {
switch (config.getLoadAnimation()) {
default:
case UPWARD:
stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
break;
case DOWNWARD:
stack.translate(0, -(1 - completion) * controller.getFinalPos().getY(), 0);
stack.translate(0, (finalPos.getY() - completion * finalPos.getY()) * config.getTranslationAmount(), 0);
break;
case UPWARD:
stack.translate(0, (-finalPos.getY() + completion * finalPos.getY()) * config.getTranslationAmount(), 0);
break;
case INWARD:
if (controller.getDirection() == null) break;
Vec3i dirVec = controller.getDirection().getVector();
double mod = -(200 - UtilEasing.easeInOutSine(completion) * 200) * config.getTranslationAmount();
stack.translate(dirVec.getX() * mod, 0, dirVec.getZ() * mod);
break;
case SCALE:
//TODO Find a way to scale centered at the middle of the chunk rather than the origin.
stack.scale((float) completion, (float) completion, (float) completion);
break;
// case INWARD:
// stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
// break;
}
if (completion >= 1.0) {
completedChunks.add(chunk.getOrigin());
animations.remove(chunk);
}
if (completion >= 1.0) animations.remove(chunk);
}
@AllArgsConstructor @Data
private static class AnimationController {
private BlockPos finalPos;
private Direction direction;
private long startTime;
}
}

View File

@ -0,0 +1,28 @@
package cc.flogi.dev.smoothchunks.mixin;
import cc.flogi.dev.smoothchunks.client.handler.ChunkAnimationHandler;
import net.minecraft.client.render.chunk.ChunkBuilder;
import net.minecraft.util.math.BlockPos;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
/**
* @author Caden Kriese (flogic)
*
* Created on 11/01/2020
*/
@Mixin(ChunkBuilder.BuiltChunk.class)
public abstract class BuiltChunkMixin {
@Shadow public abstract BlockPos getOrigin();
@Inject(
method = "clear",
at = @At(value = "TAIL")
)
public void onDelete(CallbackInfo ci) {
ChunkAnimationHandler.get().getLoadedChunks().remove(getOrigin());
}
}

View File

@ -0,0 +1,35 @@
package cc.flogi.dev.smoothchunks.mixin;
import cc.flogi.dev.smoothchunks.client.handler.ChunkAnimationHandler;
import net.minecraft.client.render.WorldRenderer;
import net.minecraft.client.render.chunk.BlockBufferBuilderStorage;
import net.minecraft.client.render.chunk.ChunkBuilder;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.concurrent.CompletableFuture;
/**
* @author Caden Kriese (flogic)
*
* Created on 10/07/2020
*/
@SuppressWarnings("rawtypes") @Mixin(ChunkBuilder.BuiltChunk.RebuildTask.class)
public abstract class RebuildTaskMixin {
//Parent class
@SuppressWarnings("ShadowTarget") @Shadow private ChunkBuilder.BuiltChunk field_20839;
@Inject(
method = "run",
at = @At(
value = "INVOKE",
target = "Ljava/util/Set;forEach(Ljava/util/function/Consumer;)V"
)
)
public void onChunkUploads(BlockBufferBuilderStorage buffers, CallbackInfoReturnable<CompletableFuture> cir) {
ChunkAnimationHandler.get().addChunk(field_20839);
}
}

View File

@ -1,6 +1,6 @@
package cc.flogi.dev.smoothchunks.mixin;
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
import cc.flogi.dev.smoothchunks.client.handler.ChunkAnimationHandler;
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
import net.minecraft.client.gl.VertexBuffer;
import net.minecraft.client.render.RenderLayer;
@ -18,7 +18,7 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
*
* Created on 09/25/2020
*/
@Mixin(WorldRenderer.class)
@SuppressWarnings("rawtypes") @Mixin(WorldRenderer.class)
public abstract class WorldRendererMixin {
@Inject(
method = "renderLayer",
@ -30,6 +30,6 @@ public abstract class WorldRendererMixin {
private void renderLayerInject(RenderLayer renderLayer, MatrixStack matrixStack, double d, double e, double f,
CallbackInfo ci, boolean bl, ObjectListIterator objectListIterator,
WorldRenderer.ChunkInfo chunkInfo2, ChunkBuilder.BuiltChunk builtChunk, VertexBuffer vertexBuffer) {
SmoothChunksClient.get().getChunkAnimationHandler().update(builtChunk, matrixStack);
ChunkAnimationHandler.get().updateChunk(builtChunk, matrixStack);
}
}

View File

@ -0,0 +1,18 @@
package cc.flogi.dev.smoothchunks.util;
/**
* @author Caden Kriese (flogic)
*
* Created on 10/24/2020
*/
public final class UtilEasing {
private static final double PI = Math.PI;
public static double easeInOutSine(double completion) {
return -((Math.cos(PI * completion) - 1) / 2);
}
public static double easeOutSine(double completion) {
return Math.sin(PI * completion / 2);
}
}

View File

@ -2,5 +2,6 @@
"text.autoconfig.smooth-chunks.title": "Smooth Chunks Config",
"text.autoconfig.smooth-chunks.option.loadAnimation": "Load Animation",
"text.autoconfig.smooth-chunks.option.duration": "Duration",
"text.autoconfig.smooth-chunks.option.translationAmount": "Translation Amount",
"text.autoconfig.smooth-chunks.option.disableNearby": "Disable for Nearby Chunks"
}

View File

@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "smooth-chunks",
"version": "@version@",
"version": "${version}",
"name": "Smooth Chunks",
"description": "Smooth chunk load animations.",
"authors": [
@ -33,6 +33,6 @@
"depends": {
"fabricloader": ">=0.9.3+build.207",
"fabric": "*",
"minecraft": "1.16.3"
"minecraft": ">=1.16.2"
}
}

View File

@ -1,3 +1,4 @@
accessWidener v1 named
accessible class net/minecraft/client/render/chunk/ChunkBuilder$BuiltChunk$RebuildTask
accessible class net/minecraft/client/render/WorldRenderer$ChunkInfo

View File

@ -5,6 +5,8 @@
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [
"BuiltChunkMixin",
"RebuildTaskMixin",
"WorldRendererMixin"
],
"injectors": {