Many tweaks and improvements, working towards first release
This commit is contained in:
parent
a12cffbff0
commit
543cb55c7f
1
.gitignore
vendored
1
.gitignore
vendored
@ -118,3 +118,4 @@ run/
|
|||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
src/main/generated/
|
src/main/generated/
|
||||||
src/test/
|
src/test/
|
||||||
|
remappedSrc/
|
||||||
|
18
build.gradle
18
build.gradle
@ -1,3 +1,5 @@
|
|||||||
|
import org.apache.tools.ant.filters.ReplaceTokens
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'fabric-loom' version '0.5-SNAPSHOT'
|
id 'fabric-loom' version '0.5-SNAPSHOT'
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
@ -19,6 +21,19 @@ dependencies {
|
|||||||
// Fabric API.
|
// Fabric API.
|
||||||
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
|
||||||
|
|
||||||
|
// Cloth Config / Autoconfig
|
||||||
|
modApi("me.shedaniel.cloth:config-2:4.8.2") {
|
||||||
|
exclude(group: "net.fabricmc.fabric-api")
|
||||||
|
exclude module: "modmenu"
|
||||||
|
}
|
||||||
|
modApi("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"
|
||||||
|
|
||||||
|
modImplementation "io.github.prospector:modmenu:1.14.6+build.31"
|
||||||
|
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.12'
|
compileOnly 'org.projectlombok:lombok:1.18.12'
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.12'
|
annotationProcessor 'org.projectlombok:lombok:1.18.12'
|
||||||
|
|
||||||
@ -35,6 +50,7 @@ processResources {
|
|||||||
|
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include "fabric.mod.json"
|
include "fabric.mod.json"
|
||||||
|
// filter(ReplaceTokens, tokens: [version: project.version])
|
||||||
expand "version": project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +67,7 @@ tasks.withType(JavaCompile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task sourcesJar(type: Jar, dependsOn: classes) {
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
||||||
classifier = "sources"
|
getArchiveClassifier().set("sources")
|
||||||
from sourceSets.main.allSource
|
from sourceSets.main.allSource
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,12 +3,12 @@ org.gradle.jvmargs=-Xmx1G
|
|||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://modmuss50.me/fabric.html
|
# check these on https://modmuss50.me/fabric.html
|
||||||
minecraft_version=1.16.3
|
minecraft_version=1.16.3
|
||||||
yarn_mappings=1.16.3+build.11
|
yarn_mappings=1.16.3+build.17
|
||||||
loader_version=0.9.3+build.207
|
loader_version=0.10.0+build.208
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.1.0-SNAPSHOT
|
mod_version=0.1.0-SNAPSHOT
|
||||||
maven_group=cc.flogi.dev
|
maven_group=cc.flogi.dev
|
||||||
archives_base_name=smooth-chunks
|
archives_base_name=smooth-chunks
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# check this on https://modmuss50.me/fabric.html
|
# check this on https://modmuss50.me/fabric.html
|
||||||
fabric_version=0.21.0+build.407-1.16
|
fabric_version=0.22.0+build.408-1.16
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
5
readme.md
Normal file
5
readme.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
![Smooth Chunks Logo](src/main/resources/assets/smooth-chunks/icon.png)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Smooth Chunks
|
@ -1,42 +0,0 @@
|
|||||||
package cc.flogi.dev.smoothchunks.client;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Caden Kriese (flogic)
|
|
||||||
*
|
|
||||||
* Created on 09/27/2020
|
|
||||||
*/
|
|
||||||
public class ChunkAnimationHandler {
|
|
||||||
private static final long DURATION = 1000;
|
|
||||||
|
|
||||||
private static final HashMap<ChunkBuilder.BuiltChunk, AnimationController> animations = new HashMap<>();
|
|
||||||
|
|
||||||
public static void update(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
|
|
||||||
AnimationController controller = animations.get(chunk);
|
|
||||||
|
|
||||||
if (controller == null) {
|
|
||||||
controller = new AnimationController(chunk.getOrigin(), System.currentTimeMillis());
|
|
||||||
animations.put(chunk, controller);
|
|
||||||
}
|
|
||||||
|
|
||||||
double completion = (double) (System.currentTimeMillis() - controller.getStartTime()) / DURATION;
|
|
||||||
completion = Math.min(completion, 1.0);
|
|
||||||
|
|
||||||
stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
|
|
||||||
|
|
||||||
if (completion >= 1.0) animations.remove(chunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor @Data
|
|
||||||
private static class AnimationController {
|
|
||||||
private BlockPos finalPos;
|
|
||||||
private long startTime;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,10 @@
|
|||||||
package cc.flogi.dev.smoothchunks.client;
|
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;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
@ -10,5 +15,18 @@ import net.fabricmc.api.Environment;
|
|||||||
* Created on 09/21/2020
|
* Created on 09/21/2020
|
||||||
*/
|
*/
|
||||||
@Environment(EnvType.CLIENT) public class SmoothChunksClient implements ClientModInitializer {
|
@Environment(EnvType.CLIENT) public class SmoothChunksClient implements ClientModInitializer {
|
||||||
@Override public void onInitializeClient() {}
|
private static SmoothChunksClient instance;
|
||||||
|
public static SmoothChunksClient get() {return instance;}
|
||||||
|
|
||||||
|
@Getter private SmoothChunksConfig config;
|
||||||
|
@Getter private ChunkAnimationHandler chunkAnimationHandler;
|
||||||
|
|
||||||
|
@Override public void onInitializeClient() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
|
AutoConfig.register(SmoothChunksConfig.class, Toml4jConfigSerializer::new);
|
||||||
|
config = AutoConfig.getConfigHolder(SmoothChunksConfig.class).getConfig();
|
||||||
|
|
||||||
|
chunkAnimationHandler = new ChunkAnimationHandler(config);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package cc.flogi.dev.smoothchunks.client.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Caden Kriese (flogic)
|
||||||
|
*
|
||||||
|
* Created on 09/28/2020
|
||||||
|
*/
|
||||||
|
public enum LoadAnimation {
|
||||||
|
DOWNWARD,
|
||||||
|
UPWARD,
|
||||||
|
INWARD,
|
||||||
|
FADE
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package cc.flogi.dev.smoothchunks.client.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.annotation.ConfigEntry;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Caden Kriese (flogic)
|
||||||
|
*
|
||||||
|
* Created on 09/28/2020
|
||||||
|
*/
|
||||||
|
@Config(name = "smooth-chunks") @Config.Gui.Background("minecraft:textures/block/stone.png") @Getter
|
||||||
|
public class SmoothChunksConfig implements ConfigData {
|
||||||
|
@Comment("Duration of the animation in seconds.")
|
||||||
|
@ConfigEntry.BoundedDiscrete(min = 0, max=10)
|
||||||
|
int duration = 1;
|
||||||
|
|
||||||
|
@Comment("Type of animation for loading chunks.")
|
||||||
|
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
|
||||||
|
LoadAnimation loadAnimation = LoadAnimation.DOWNWARD;
|
||||||
|
|
||||||
|
@Comment("Disable animating chunks close to you")
|
||||||
|
boolean disableNearby = false;
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package cc.flogi.dev.smoothchunks.client.config;
|
||||||
|
|
||||||
|
import io.github.prospector.modmenu.api.ConfigScreenFactory;
|
||||||
|
import io.github.prospector.modmenu.api.ModMenuApi;
|
||||||
|
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
|
||||||
|
import net.fabricmc.api.EnvType;
|
||||||
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Caden Kriese (flogic)
|
||||||
|
*
|
||||||
|
* Created on 09/28/2020
|
||||||
|
*/
|
||||||
|
@Environment(EnvType.CLIENT)
|
||||||
|
public class SmoothChunksModMenu implements ModMenuApi {
|
||||||
|
@Override
|
||||||
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
|
return (ConfigScreenFactory<Screen>) parent -> AutoConfig.getConfigScreen(SmoothChunksConfig.class, parent).get();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package cc.flogi.dev.smoothchunks.client.handler;
|
||||||
|
|
||||||
|
import cc.flogi.dev.smoothchunks.client.config.LoadAnimation;
|
||||||
|
import cc.flogi.dev.smoothchunks.client.config.SmoothChunksConfig;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Caden Kriese (flogic)
|
||||||
|
*
|
||||||
|
* Created on 09/27/2020
|
||||||
|
*/
|
||||||
|
public final class ChunkAnimationHandler {
|
||||||
|
private final long DURATION;
|
||||||
|
private final LoadAnimation LOAD_ANIMATION;
|
||||||
|
private final boolean DISABLE_NEARBY;
|
||||||
|
|
||||||
|
private final WeakHashMap<ChunkBuilder.BuiltChunk, AnimationController> animations = new WeakHashMap<>();
|
||||||
|
private final List<BlockPos> completedChunks = new ArrayList<>();
|
||||||
|
|
||||||
|
public ChunkAnimationHandler(SmoothChunksConfig config) {
|
||||||
|
DURATION = config.getDuration() * 1000;
|
||||||
|
LOAD_ANIMATION = config.getLoadAnimation();
|
||||||
|
DISABLE_NEARBY = config.isDisableNearby();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
|
||||||
|
if (completedChunks.contains(chunk.getOrigin())) return;
|
||||||
|
|
||||||
|
AnimationController controller = animations.get(chunk);
|
||||||
|
|
||||||
|
if (controller == null) {
|
||||||
|
controller = new AnimationController(chunk.getOrigin(), System.currentTimeMillis());
|
||||||
|
animations.put(chunk, controller);
|
||||||
|
}
|
||||||
|
|
||||||
|
double completion = (double) (System.currentTimeMillis() - controller.getStartTime()) / DURATION;
|
||||||
|
completion = Math.min(completion, 1.0);
|
||||||
|
|
||||||
|
switch (LOAD_ANIMATION) {
|
||||||
|
default:
|
||||||
|
case UPWARD:
|
||||||
|
stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
|
||||||
|
break;
|
||||||
|
case DOWNWARD:
|
||||||
|
stack.translate(0, -(1 - completion) * controller.getFinalPos().getY(), 0);
|
||||||
|
break;
|
||||||
|
// case INWARD:
|
||||||
|
// stack.translate(0, (1 - completion) * controller.getFinalPos().getY(), 0);
|
||||||
|
// break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (completion >= 1.0) {
|
||||||
|
completedChunks.add(chunk.getOrigin());
|
||||||
|
animations.remove(chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor @Data
|
||||||
|
private static class AnimationController {
|
||||||
|
private BlockPos finalPos;
|
||||||
|
private long startTime;
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,13 @@
|
|||||||
package cc.flogi.dev.smoothchunks.mixin;
|
package cc.flogi.dev.smoothchunks.mixin;
|
||||||
|
|
||||||
import cc.flogi.dev.smoothchunks.client.ChunkAnimationHandler;
|
import cc.flogi.dev.smoothchunks.client.SmoothChunksClient;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectList;
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||||
import net.minecraft.client.gl.VertexBuffer;
|
import net.minecraft.client.gl.VertexBuffer;
|
||||||
import net.minecraft.client.render.BuiltChunkStorage;
|
|
||||||
import net.minecraft.client.render.RenderLayer;
|
import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.WorldRenderer;
|
import net.minecraft.client.render.WorldRenderer;
|
||||||
import net.minecraft.client.render.chunk.ChunkBuilder;
|
import net.minecraft.client.render.chunk.ChunkBuilder;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.client.world.ClientWorld;
|
|
||||||
import org.spongepowered.asm.mixin.Final;
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
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.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Inject;
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
@ -32,12 +27,9 @@ public abstract class WorldRendererMixin {
|
|||||||
target = "Lnet/minecraft/client/gl/VertexBuffer;bind()V"),
|
target = "Lnet/minecraft/client/gl/VertexBuffer;bind()V"),
|
||||||
locals = LocalCapture.CAPTURE_FAILHARD
|
locals = LocalCapture.CAPTURE_FAILHARD
|
||||||
)
|
)
|
||||||
private void rotateRender(RenderLayer renderLayer, MatrixStack matrixStack, double d, double e, double f,
|
private void renderLayerInject(RenderLayer renderLayer, MatrixStack matrixStack, double d, double e, double f,
|
||||||
CallbackInfo ci, boolean bl, ObjectListIterator objectListIterator,
|
CallbackInfo ci, boolean bl, ObjectListIterator objectListIterator,
|
||||||
WorldRenderer.ChunkInfo chunkInfo2, ChunkBuilder.BuiltChunk builtChunk, VertexBuffer vertexBuffer) {
|
WorldRenderer.ChunkInfo chunkInfo2, ChunkBuilder.BuiltChunk builtChunk, VertexBuffer vertexBuffer) {
|
||||||
int chunkX = builtChunk.getOrigin().getX() / 16;
|
SmoothChunksClient.get().getChunkAnimationHandler().update(builtChunk, matrixStack);
|
||||||
int chunkZ = builtChunk.getOrigin().getZ() / 16;
|
|
||||||
|
|
||||||
ChunkAnimationHandler.update(builtChunk, matrixStack);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 36 KiB |
6
src/main/resources/assets/smooth-chunks/lang/en_us.json
Normal file
6
src/main/resources/assets/smooth-chunks/lang/en_us.json
Normal file
@ -0,0 +1,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.disableNearby": "Disable for Nearby Chunks"
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"schemaVersion": 1,
|
"schemaVersion": 1,
|
||||||
"id": "smooth-chunks",
|
"id": "smooth-chunks",
|
||||||
"version": "${version}",
|
"version": "@version@",
|
||||||
"name": "Smooth Chunks",
|
"name": "Smooth Chunks",
|
||||||
"description": "Smooth chunk load animations.",
|
"description": "Smooth chunk load animations.",
|
||||||
"authors": [
|
"authors": [
|
||||||
@ -12,10 +12,14 @@
|
|||||||
"repo": "repo.flogi.cc"
|
"repo": "repo.flogi.cc"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"accessWidener" : "smooth-chunks.accesswidener",
|
|
||||||
"icon": "assets/smooth-chunks/icon.png",
|
"icon": "assets/smooth-chunks/icon.png",
|
||||||
"environment": "client",
|
"environment": "client",
|
||||||
|
"accessWidener": "smooth-chunks.accesswidener",
|
||||||
|
"modmenu:clientsideOnly": "true",
|
||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
|
"modmenu": [
|
||||||
|
"cc.flogi.dev.smoothchunks.client.config.SmoothChunksModMenu"
|
||||||
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"cc.flogi.dev.smoothchunks.client.SmoothChunksClient"
|
"cc.flogi.dev.smoothchunks.client.SmoothChunksClient"
|
||||||
],
|
],
|
||||||
|
3
src/main/resources/smooth-chunks.accesswidener
Normal file
3
src/main/resources/smooth-chunks.accesswidener
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
accessWidener v1 named
|
||||||
|
|
||||||
|
accessible class net/minecraft/client/render/WorldRenderer$ChunkInfo
|
@ -3,11 +3,8 @@
|
|||||||
"minVersion": "0.8",
|
"minVersion": "0.8",
|
||||||
"package": "cc.flogi.dev.smoothchunks.mixin",
|
"package": "cc.flogi.dev.smoothchunks.mixin",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"mixins": [
|
"mixins": [],
|
||||||
"BuiltChunkMixin"
|
|
||||||
],
|
|
||||||
"client": [
|
"client": [
|
||||||
"BuiltChunkStorageMixin",
|
|
||||||
"WorldRendererMixin"
|
"WorldRendererMixin"
|
||||||
],
|
],
|
||||||
"injectors": {
|
"injectors": {
|
||||||
|
Loading…
Reference in New Issue
Block a user