Topcheto eu/sodium compatibility issue (#19)
* chore: clean up codebase, note sodium incompatibility * fix: some rendering issues due to refactoring
This commit is contained in:
parent
b9357832fb
commit
54c77dced0
@ -14,6 +14,8 @@ An enhanecd fork of [cadenkriese's mod](https://github.com/cadenkriese/smooth-ch
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
**NOTE: This mod WILL NOT support Sodium, since Sodium doesn't render separate chunks, but whole regions, hence separate chunk animations are rendered impossible. Anyone interested in making sodium compatibility, be my guest**
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|
||||||
Animated Chunks is a Fabric mod that adds animations of currently loading chunks. This makes chunk loading generally seem much more pleasant than them appearing out of thin air. There are multiple built-in animations and ease types, and if this isnt't enough, there's an API which will allow you to add your own animations and eases<br/>(with ease :trollface:)
|
Animated Chunks is a Fabric mod that adds animations of currently loading chunks. This makes chunk loading generally seem much more pleasant than them appearing out of thin air. There are multiple built-in animations and ease types, and if this isnt't enough, there's an API which will allow you to add your own animations and eases<br/>(with ease :trollface:)
|
||||||
@ -47,7 +49,7 @@ Generally, this is what you'd call an "eye-candy" mod.
|
|||||||
|
|
||||||
## Future plans
|
## Future plans
|
||||||
|
|
||||||
In the future, I plan to extend the scope of this mod to not only smoothen the chunk loading, but entity spawning/despawning/dying, liquid flowing, crops growing etc. and support Sodium.
|
In the future, I plan to extend the scope of this mod to not only smoothen the chunk loading, but entity spawning/despawning/dying, liquid flowing, crops growing etc.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url "https://maven.terraformersmc.com/releases"
|
url "https://maven.terraformersmc.com/releases"
|
||||||
}
|
}
|
||||||
|
// maven {
|
||||||
|
// url "https://jitpack.io/"
|
||||||
|
// }
|
||||||
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -50,6 +54,7 @@ dependencies {
|
|||||||
// include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}")
|
// include("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig_version}")
|
||||||
|
|
||||||
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
|
modImplementation("com.terraformersmc:modmenu:${project.modmenu_version}")
|
||||||
|
// modImplementation("com.github.CaffeineMC:sodium-fabric:${project.sodium_version}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@ org.gradle.jvmargs=-Xmx4G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
minecraft_version=1.19.2
|
minecraft_version=1.19.2
|
||||||
yarn_mappings=1.19.2+build.20
|
yarn_mappings=1.19.2+build.28
|
||||||
loader_version=0.14.9
|
loader_version=0.14.12
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=0.3.0
|
mod_version=0.3.0
|
||||||
@ -15,3 +15,4 @@ archives_base_name=animated-chunks
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
fabric_version=0.72.0+1.19.2
|
fabric_version=0.72.0+1.19.2
|
||||||
modmenu_version=4.1.2
|
modmenu_version=4.1.2
|
||||||
|
# sodium_version=mc1.19.2-0.4.3
|
||||||
|
@ -5,11 +5,10 @@ import java.io.File;
|
|||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.Manager.RegisterEvent;
|
|
||||||
import me.topchetoeu.animatedchunks.animation.Animation;
|
import me.topchetoeu.animatedchunks.animation.Animation;
|
||||||
import me.topchetoeu.animatedchunks.animation.FallAnimation;
|
import me.topchetoeu.animatedchunks.animation.FallAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.FlyInAnimation;
|
import me.topchetoeu.animatedchunks.animation.FlyInAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
import me.topchetoeu.animatedchunks.animation.Animator;
|
||||||
import me.topchetoeu.animatedchunks.animation.RiseAnimation;
|
import me.topchetoeu.animatedchunks.animation.RiseAnimation;
|
||||||
import me.topchetoeu.animatedchunks.animation.ScaleAnimation;
|
import me.topchetoeu.animatedchunks.animation.ScaleAnimation;
|
||||||
import me.topchetoeu.animatedchunks.easing.Ease;
|
import me.topchetoeu.animatedchunks.easing.Ease;
|
||||||
@ -20,54 +19,27 @@ import me.topchetoeu.animatedchunks.easing.SineEase;
|
|||||||
import me.topchetoeu.animatedchunks.gui.AnimatedChunksScreen;
|
import me.topchetoeu.animatedchunks.gui.AnimatedChunksScreen;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientChunkEvents;
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
||||||
private static AnimatedChunks instance;
|
private static AnimatedChunks instance;
|
||||||
|
/**
|
||||||
|
* Gets the currently running instance of this mod
|
||||||
|
*/
|
||||||
public static AnimatedChunks getInstance() {
|
public static AnimatedChunks getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An event, fired once, when eases are being registered
|
* The animator used by the mod. Used to manage animation progress and animate chunks
|
||||||
*/
|
*/
|
||||||
public final Event<RegisterEvent<Ease>> EASES_REGISTERING = Manager.createEvent();
|
public final Animator animator;
|
||||||
/**
|
/**
|
||||||
* An event, fired once, when animations are being registered
|
* The config manager used by the mod. Used to save/load config from disk
|
||||||
*/
|
*/
|
||||||
public final Event<RegisterEvent<Animation>> ANIMATIONS_REGISTERING = Manager.createEvent();
|
public final ConfigManager config;
|
||||||
|
|
||||||
private ProgressManager progress;
|
|
||||||
private ConfigManager config;
|
|
||||||
private Manager<Ease> ease;
|
|
||||||
private Manager<Animation> animation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the config manager
|
|
||||||
*/
|
|
||||||
public ConfigManager getConfigManager() {
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets the chunk progress manager
|
|
||||||
*/
|
|
||||||
public ProgressManager getProgressManager() {
|
|
||||||
return progress;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets the animation manager
|
|
||||||
*/
|
|
||||||
public Manager<Animation> getAnimationManager() {
|
|
||||||
return animation;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Gets the ease manager
|
|
||||||
*/
|
|
||||||
public Manager<Ease> getEaseManager() {
|
|
||||||
return ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerEases(Manager<Ease> manager) {
|
private static void registerEases(Manager<Ease> manager) {
|
||||||
manager.register(new Descriptor<>(new LinearEase(), "linear")
|
manager.register(new Descriptor<>(new LinearEase(), "linear")
|
||||||
@ -121,34 +93,35 @@ public final class AnimatedChunks implements ClientModInitializer, ModMenuApi {
|
|||||||
@Override public void onInitializeClient() {
|
@Override public void onInitializeClient() {
|
||||||
instance = this;
|
instance = this;
|
||||||
|
|
||||||
progress = new ProgressManager();
|
|
||||||
ease = new Manager<>(x -> 1);
|
|
||||||
ease.get()
|
|
||||||
.description("Ends the animation as soon as it has started.")
|
|
||||||
.displayName("No animation");
|
|
||||||
animation = new Manager<>((a, b, c, d, e, f, g, h) -> {});
|
|
||||||
animation.get()
|
|
||||||
.description("Does nothing.")
|
|
||||||
.displayName("No animation");
|
|
||||||
|
|
||||||
registerEases(ease);
|
|
||||||
registerAnimations(animation);
|
|
||||||
|
|
||||||
config = new ConfigManager(new File("config/animated-chunks.dat"), animation, ease, progress);
|
|
||||||
|
|
||||||
EASES_REGISTERING.invoker().register(ease);
|
|
||||||
ANIMATIONS_REGISTERING.invoker().register(animation);
|
|
||||||
|
|
||||||
ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> {
|
ClientChunkEvents.CHUNK_UNLOAD.register((world, chunk) -> {
|
||||||
BlockPos pos = chunk.getPos().getStartPos();
|
BlockPos pos = chunk.getPos().getStartPos();
|
||||||
progress.unload(pos.getX(), pos.getY(), pos.getZ());
|
animator.unload(pos.getX(), pos.getY(), pos.getZ());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return (Screen parent) -> {
|
return (Screen parent) -> {
|
||||||
var _this = getInstance();
|
var _this = getInstance();
|
||||||
return new AnimatedChunksScreen(parent, _this.animation, _this.ease, _this.config, _this.progress);
|
return new AnimatedChunksScreen(parent, _this.config, _this.animator);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AnimatedChunks() {
|
||||||
|
var eases = new Manager<>(new Descriptor<Ease>(x -> 1, "default")
|
||||||
|
.author("TopchetoEU")
|
||||||
|
.description("Ends the animation as soon as it has started.")
|
||||||
|
.displayName("No animation")
|
||||||
|
);
|
||||||
|
var animations = new Manager<>(new Descriptor<Animation>((a, b, c, d, e, f, g, h) -> {}, "default")
|
||||||
|
.author("TopchetoEU")
|
||||||
|
.description("Does nothing.")
|
||||||
|
.displayName("No animation")
|
||||||
|
);
|
||||||
|
|
||||||
|
registerEases(eases);
|
||||||
|
registerAnimations(animations);
|
||||||
|
|
||||||
|
animator = new Animator(animations, eases);
|
||||||
|
config = new ConfigManager(new File("config/animated-chunks.dat"), animator);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,15 +9,11 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.animation.Animation;
|
import me.topchetoeu.animatedchunks.animation.Animator;
|
||||||
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
|
||||||
import me.topchetoeu.animatedchunks.easing.Ease;
|
|
||||||
|
|
||||||
public class ConfigManager {
|
public class ConfigManager {
|
||||||
public final File configFile;
|
public final File configFile;
|
||||||
private final Manager<Animation> animation;
|
private final Animator animator;
|
||||||
private final Manager<Ease> ease;
|
|
||||||
private final ProgressManager progress;
|
|
||||||
|
|
||||||
private String readString(InputStream reader) throws IOException {
|
private String readString(InputStream reader) throws IOException {
|
||||||
String res = "";
|
String res = "";
|
||||||
@ -56,9 +52,9 @@ public class ConfigManager {
|
|||||||
|
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
this.animation.set(animation);
|
this.animator.ANIMATIONS.set(animation);
|
||||||
this.ease.set(ease);
|
this.animator.EASES.set(ease);
|
||||||
this.progress.setDuration(duration);
|
this.animator.setDuration(duration);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
save();
|
save();
|
||||||
@ -67,9 +63,9 @@ public class ConfigManager {
|
|||||||
public void save() {
|
public void save() {
|
||||||
try {
|
try {
|
||||||
var writer = new FileOutputStream(configFile);
|
var writer = new FileOutputStream(configFile);
|
||||||
writeString(writer, animation.get().getName());
|
writeString(writer, this.animator.ANIMATIONS.get().getName());
|
||||||
writeString(writer, ease.get().getName());
|
writeString(writer, this.animator.EASES.get().getName());
|
||||||
writer.write(ByteBuffer.allocate(4).putFloat(progress.getDuration()).array());
|
writer.write(ByteBuffer.allocate(4).putFloat(animator.getDuration()).array());
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
@ -77,11 +73,9 @@ public class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigManager(File configFile, Manager<Animation> animation, Manager<Ease> ease, ProgressManager progress) {
|
public ConfigManager(File configFile, Animator animator) {
|
||||||
this.configFile = configFile;
|
this.configFile = configFile;
|
||||||
this.animation = animation;
|
this.animator = animator;
|
||||||
this.ease = ease;
|
|
||||||
this.progress = progress;
|
|
||||||
|
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
import net.fabricmc.fabric.api.event.Event;
|
|
||||||
import net.fabricmc.fabric.api.event.EventFactory;
|
|
||||||
|
|
||||||
public final class Manager<T> {
|
public final class Manager<T> {
|
||||||
public static interface RegisterEvent<T> {
|
|
||||||
public void register(Manager<T> manager);
|
|
||||||
}
|
|
||||||
public static final <T> Event<RegisterEvent<T>> createEvent() {
|
|
||||||
return EventFactory.createArrayBacked(RegisterEvent.class, (listeners) -> (manager) -> {
|
|
||||||
for (RegisterEvent<T> listener: listeners) {
|
|
||||||
listener.register(manager);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private String currName = null;
|
private String currName = null;
|
||||||
private Map<String, Descriptor<T>> objects = new Hashtable<>();
|
private Map<String, Descriptor<T>> objects = new Hashtable<>();
|
||||||
|
|
||||||
@ -75,8 +61,8 @@ public final class Manager<T> {
|
|||||||
return Collections.unmodifiableCollection(objects.values());
|
return Collections.unmodifiableCollection(objects.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Manager(T _default) {
|
public Manager(Descriptor<T> _default) {
|
||||||
register(new Descriptor<>(_default, "default").displayName("Default").author("TopchetoEU"));
|
register(_default);
|
||||||
set("default");
|
set("default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,146 +1,184 @@
|
|||||||
package me.topchetoeu.animatedchunks.animation;
|
package me.topchetoeu.animatedchunks.animation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
public final class ProgressManager {
|
import me.topchetoeu.animatedchunks.Manager;
|
||||||
public static class ChunkLoc {
|
import me.topchetoeu.animatedchunks.easing.Ease;
|
||||||
public final int x;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
public final int y;
|
import net.minecraft.client.util.math.Vector3d;
|
||||||
public final int z;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
@Override
|
public final class Animator {
|
||||||
public boolean equals(Object obj) {
|
public static class ChunkLoc {
|
||||||
return obj instanceof ChunkLoc && ((ChunkLoc)obj).x == x && ((ChunkLoc)obj).y == y && ((ChunkLoc)obj).z == z;
|
public final int x;
|
||||||
}
|
public final int y;
|
||||||
|
public final int z;
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
@Override
|
||||||
return 137 * x + 149 * y + 163 * z;
|
public boolean equals(Object obj) {
|
||||||
}
|
return obj instanceof ChunkLoc && ((ChunkLoc)obj).x == x && ((ChunkLoc)obj).y == y && ((ChunkLoc)obj).z == z;
|
||||||
|
}
|
||||||
public ChunkLoc(int x, int y, int z) {
|
@Override
|
||||||
this.x = x;
|
public int hashCode() {
|
||||||
this.y = y;
|
return 137 * x + 149 * y + 163 * z;
|
||||||
this.z = z;
|
}
|
||||||
}
|
|
||||||
}
|
public ChunkLoc(int x, int y, int z) {
|
||||||
|
this.x = x;
|
||||||
private Hashtable<ChunkLoc, Float> chunkToStage = new Hashtable<>();
|
this.y = y;
|
||||||
private HashSet<ChunkLoc> chunks = new HashSet<>();
|
this.z = z;
|
||||||
private float duration = 1;
|
}
|
||||||
|
}
|
||||||
public ProgressManager() {
|
|
||||||
|
public final Manager<Animation> ANIMATIONS;
|
||||||
}
|
public final Manager<Ease> EASES;
|
||||||
|
|
||||||
public float getDuration() {
|
private Hashtable<ChunkLoc, Float> chunkToStage = new Hashtable<>();
|
||||||
return duration;
|
private HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||||
}
|
private float duration = 1;
|
||||||
public void setDuration(float duration) {
|
|
||||||
this.duration = duration;
|
public Animator(Manager<Animation> animations, Manager<Ease> eases) {
|
||||||
}
|
ANIMATIONS = animations;
|
||||||
|
EASES = eases;
|
||||||
/**
|
}
|
||||||
* Removes all loaded chunks (called when a world is unloaded and loaded)
|
|
||||||
*/
|
public float getDuration() {
|
||||||
public void reset() {
|
return duration;
|
||||||
chunkToStage.clear();
|
}
|
||||||
chunks.clear();
|
public void setDuration(float duration) {
|
||||||
}
|
this.duration = duration;
|
||||||
/**
|
}
|
||||||
* Advances the animation for all tracked chunks, according to the duration and the specified delta
|
|
||||||
* @param delta The second delta to advance the animation by
|
/**
|
||||||
*/
|
* Removes all loaded chunks (called when a world is unloaded and loaded)
|
||||||
public void tick(float delta) {
|
*/
|
||||||
for (ChunkLoc loc : new ArrayList<>(chunkToStage.keySet())) {
|
public void reset() {
|
||||||
float val = chunkToStage.get(loc);
|
chunkToStage.clear();
|
||||||
val += delta / duration;
|
chunks.clear();
|
||||||
if (val > 1f) chunkToStage.remove(loc);
|
}
|
||||||
chunkToStage.put(loc, val);
|
/**
|
||||||
}
|
* Advances the animation for all tracked chunks, according to the duration and the specified delta
|
||||||
}
|
* @param delta The second delta to advance the animation by
|
||||||
|
*/
|
||||||
/**
|
public void tick(float delta) {
|
||||||
* Loads a specified chunk (starts tracking its animation)
|
for (ChunkLoc loc : new ArrayList<>(chunkToStage.keySet())) {
|
||||||
* @param x The x of the chunk
|
float val = chunkToStage.get(loc);
|
||||||
* @param y The y of the chunk
|
val += delta / duration;
|
||||||
* @param y The z of the chunk
|
if (val > 1f) chunkToStage.remove(loc);
|
||||||
*/
|
chunkToStage.put(loc, val);
|
||||||
public void load(int x, int y, int z) {
|
}
|
||||||
if (isChunkLoaded(x, y, z)) return;
|
}
|
||||||
ChunkLoc loc = new ChunkLoc(x, y, z);
|
|
||||||
chunks.add(loc);
|
/**
|
||||||
chunkToStage.put(loc, 0f);
|
* Loads a specified chunk (starts tracking its animation)
|
||||||
}
|
* @param x The x of the chunk
|
||||||
/**
|
* @param y The y of the chunk
|
||||||
* Unloads a specified chunk (stops tracking its animation)
|
* @param y The z of the chunk
|
||||||
* @param x The x of the chunk
|
*/
|
||||||
* @param y The y of the chunk
|
public void load(int x, int y, int z) {
|
||||||
* @param y The z of the chunk
|
if (isChunkLoaded(x, y, z)) return;
|
||||||
*/
|
ChunkLoc loc = new ChunkLoc(x, y, z);
|
||||||
public void unload(int x, int y, int z) {
|
chunks.add(loc);
|
||||||
ChunkLoc loc = new ChunkLoc(x, y, z);
|
chunkToStage.put(loc, 0f);
|
||||||
chunkToStage.remove(loc);
|
}
|
||||||
chunks.remove(loc);
|
/**
|
||||||
}
|
* Unloads a specified chunk (stops tracking its animation)
|
||||||
/**
|
* @param x The x of the chunk
|
||||||
* Unloads all loaded chunks
|
* @param y The y of the chunk
|
||||||
*/
|
* @param y The z of the chunk
|
||||||
public void unloadAll() {
|
*/
|
||||||
chunkToStage.clear();
|
public void unload(int x, int y, int z) {
|
||||||
chunks.clear();
|
ChunkLoc loc = new ChunkLoc(x, y, z);
|
||||||
}
|
chunkToStage.remove(loc);
|
||||||
/**
|
chunks.remove(loc);
|
||||||
* Unloads all the chunks that are outside the render distance specified
|
}
|
||||||
* @param viewDistance The view distance (in chunks, radius)
|
/**
|
||||||
* @param playerChunkX The x coordinate of the chunk in which the player stands
|
* Unloads all loaded chunks
|
||||||
* @param playerChunkY The y coordinate of the chunk in which the player stands
|
*/
|
||||||
* @param playerChunkZ The z coordinate of the chunk in which the player stands
|
public void unloadAll() {
|
||||||
*/
|
chunkToStage.clear();
|
||||||
public void unloadAllFar(int viewDistance, int playerChunkX, int playerChunkY, int playerChunkZ) {
|
chunks.clear();
|
||||||
float circleVD = viewDistance + 1.38f;
|
}
|
||||||
int squareVD = viewDistance;
|
/**
|
||||||
|
* Unloads all the chunks that are outside the render distance specified
|
||||||
for (ChunkLoc loc : new ArrayList<>(chunks)) {
|
* @param viewDistance The view distance (in chunks, radius)
|
||||||
int chunkX = loc.x / 16;
|
* @param playerChunkX The x coordinate of the chunk in which the player stands
|
||||||
int chunkZ = loc.z / 16;
|
* @param playerChunkY The y coordinate of the chunk in which the player stands
|
||||||
|
* @param playerChunkZ The z coordinate of the chunk in which the player stands
|
||||||
int diffSquareX = playerChunkX - chunkX ;
|
*/
|
||||||
int diffSquareZ = playerChunkZ - chunkZ;
|
public void unloadAllFar(int viewDistance, int playerChunkX, int playerChunkY, int playerChunkZ) {
|
||||||
|
float circleVD = viewDistance + 1.38f;
|
||||||
int diffCircleX = playerChunkX - chunkX;
|
int squareVD = viewDistance;
|
||||||
int diffCircleZ = playerChunkZ - chunkZ;
|
|
||||||
|
for (ChunkLoc loc : new ArrayList<>(chunks)) {
|
||||||
int dist = diffCircleX * diffCircleX + diffCircleZ * diffCircleZ;
|
int chunkX = loc.x / 16;
|
||||||
|
int chunkZ = loc.z / 16;
|
||||||
if (dist > circleVD * circleVD) unload(loc.x, loc.y, loc.z);
|
|
||||||
if (Math.abs(diffSquareX) > squareVD || Math.abs(diffSquareZ) > squareVD) unload(loc.x, loc.y, loc.z);
|
int diffSquareX = playerChunkX - chunkX ;
|
||||||
}
|
int diffSquareZ = playerChunkZ - chunkZ;
|
||||||
}
|
|
||||||
|
int diffCircleX = playerChunkX - chunkX;
|
||||||
/**
|
int diffCircleZ = playerChunkZ - chunkZ;
|
||||||
* Checks whether or not a chunk is loaded
|
|
||||||
* @param x The x of the chunk
|
int dist = diffCircleX * diffCircleX + diffCircleZ * diffCircleZ;
|
||||||
* @param y The y of the chunk
|
|
||||||
* @param y The z of the chunk
|
if (dist > circleVD * circleVD) unload(loc.x, loc.y, loc.z);
|
||||||
* @return A value indicating whether or not the specified chunk is tracked
|
if (Math.abs(diffSquareX) > squareVD || Math.abs(diffSquareZ) > squareVD) unload(loc.x, loc.y, loc.z);
|
||||||
*/
|
}
|
||||||
public boolean isChunkLoaded(int x, int y, int z) {
|
}
|
||||||
return chunks.contains(new ChunkLoc(x, y, z));
|
|
||||||
}
|
/**
|
||||||
|
* Checks whether or not a chunk is loaded
|
||||||
/**
|
* @param x The x of the chunk
|
||||||
* Gets the animation progress of the specified chunk
|
* @param y The y of the chunk
|
||||||
* @param x The x of the chunk
|
* @param y The z of the chunk
|
||||||
* @param y The y of the chunk
|
* @return A value indicating whether or not the specified chunk is tracked
|
||||||
* @param y The z of the chunk
|
*/
|
||||||
* @return A float value from 0 to 1 (0 if the chunk is not tracked), indicating the animation progress of the specified chunk
|
public boolean isChunkLoaded(int x, int y, int z) {
|
||||||
*/
|
return chunks.contains(new ChunkLoc(x, y, z));
|
||||||
public float getChunkProgress(int x, int y, int z) {
|
}
|
||||||
if (!isChunkLoaded(x, y, z)) return 0f;
|
|
||||||
if (!chunkToStage.containsKey(new ChunkLoc(x, y, z))) return 1f;
|
/**
|
||||||
return chunkToStage.get(new ChunkLoc(x, y, z));
|
* Gets the animation progress of the specified chunk
|
||||||
}
|
* @param x The x of the chunk
|
||||||
}
|
* @param y The y of the chunk
|
||||||
|
* @param y The z of the chunk
|
||||||
|
* @return A float value from 0 to 1 (0 if the chunk is not tracked), indicating the animation progress of the specified chunk
|
||||||
|
*/
|
||||||
|
public float getChunkProgress(int x, int y, int z) {
|
||||||
|
if (!isChunkLoaded(x, y, z)) return 0f;
|
||||||
|
if (!chunkToStage.containsKey(new ChunkLoc(x, y, z))) return 1f;
|
||||||
|
return chunkToStage.get(new ChunkLoc(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animate(MatrixStack matrices, float progress, BlockPos chunkPos, Vector3d playerPos) {
|
||||||
|
if (progress < 0) progress = 0;
|
||||||
|
if (progress > 1) progress = 1;
|
||||||
|
if (progress < 0.999) {
|
||||||
|
float _progress = EASES.getValue().ease(progress);
|
||||||
|
ANIMATIONS.getValue().animate(
|
||||||
|
_progress, matrices,
|
||||||
|
chunkPos.getX() * 16, chunkPos.getY() * 16, chunkPos.getZ() * 16,
|
||||||
|
(float)playerPos.x, (float)playerPos.y, (float)playerPos.z
|
||||||
|
);
|
||||||
|
// matrices.translate(0, 0, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void animate(MatrixStack matrices, BlockPos chunkPos, Vector3d playerPos) {
|
||||||
|
if (!isChunkLoaded(chunkPos.getX(), chunkPos.getY(), chunkPos.getZ())) {
|
||||||
|
matrices.scale(0, 0, 0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
animate(matrices, getChunkProgress(chunkPos.getX(), chunkPos.getY(), chunkPos.getZ()), chunkPos, playerPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void animate(MatrixStack matrices, BlockPos chunkPos) {
|
||||||
|
animate(matrices, chunkPos, new Vector3d(0, 0, 0));
|
||||||
|
}
|
||||||
|
public void animate(MatrixStack matrices, float progress, BlockPos chunkPos) {
|
||||||
|
animate(matrices, progress, chunkPos, new Vector3d(0, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
@ -9,19 +9,15 @@ import net.minecraft.util.Formatting;
|
|||||||
import net.minecraft.util.math.ColorHelper.Argb;
|
import net.minecraft.util.math.ColorHelper.Argb;
|
||||||
import me.topchetoeu.animatedchunks.ConfigManager;
|
import me.topchetoeu.animatedchunks.ConfigManager;
|
||||||
import me.topchetoeu.animatedchunks.Manager;
|
import me.topchetoeu.animatedchunks.Manager;
|
||||||
import me.topchetoeu.animatedchunks.animation.Animation;
|
import me.topchetoeu.animatedchunks.animation.Animator;
|
||||||
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
|
||||||
import me.topchetoeu.animatedchunks.easing.Ease;
|
|
||||||
import me.topchetoeu.animatedchunks.gui.Section.OrderType;
|
import me.topchetoeu.animatedchunks.gui.Section.OrderType;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
|
||||||
public class AnimatedChunksScreen extends Screen {
|
public class AnimatedChunksScreen extends Screen {
|
||||||
public final Screen parent;
|
public final Screen parent;
|
||||||
private final HorizontalSection mainSection = new HorizontalSection();
|
private final HorizontalSection mainSection = new HorizontalSection();
|
||||||
private final Manager<Animation> animation;
|
|
||||||
private final Manager<Ease> ease;
|
|
||||||
private final ConfigManager config;
|
private final ConfigManager config;
|
||||||
private final ProgressManager progress;
|
private final Animator animator;
|
||||||
|
|
||||||
public static void playClick() {
|
public static void playClick() {
|
||||||
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
MinecraftClient.getInstance().getSoundManager().play(PositionedSoundInstance.master(SoundEvents.UI_BUTTON_CLICK, 1.0f));
|
||||||
@ -65,7 +61,7 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
res.x = res.y = 5;
|
res.x = res.y = 5;
|
||||||
res.title = Text.of("Preview:");
|
res.title = Text.of("Preview:");
|
||||||
|
|
||||||
res.children.addSelectableChild(new ChunkPreview(0, 0, 150, 150));
|
res.children.addSelectableChild(new ChunkPreview(0, 0, 150, 150, animator));
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -100,10 +96,10 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
private Section durationSection() {
|
private Section durationSection() {
|
||||||
var res = new HorizontalSection();
|
var res = new HorizontalSection();
|
||||||
res.setTargetWidth(width / 2);
|
res.setTargetWidth(width / 2);
|
||||||
var input = new NumberInput(res, 5, 5, progress.getDuration(), (sender, val) -> {
|
var input = new NumberInput(res, 5, 5, animator.getDuration(), (sender, val) -> {
|
||||||
if (val <= 0) sender.invalid = true;
|
if (val <= 0) sender.invalid = true;
|
||||||
else {
|
else {
|
||||||
progress.setDuration(val);
|
animator.setDuration(val);
|
||||||
sender.invalid = false;
|
sender.invalid = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -117,18 +113,16 @@ public class AnimatedChunksScreen extends Screen {
|
|||||||
var res = new HorizontalSection();
|
var res = new HorizontalSection();
|
||||||
res.x = res.y = 5;
|
res.x = res.y = 5;
|
||||||
res.title = Text.of("Animation config:");
|
res.title = Text.of("Animation config:");
|
||||||
res.children.addSelectableChild(selectionSection(animation, "Animation"));
|
res.children.addSelectableChild(selectionSection(animator.ANIMATIONS, "Animation"));
|
||||||
res.children.addSelectableChild(selectionSection(ease, "Ease"));
|
res.children.addSelectableChild(selectionSection(animator.EASES, "Ease"));
|
||||||
res.children.addSelectableChild(durationSection());
|
res.children.addSelectableChild(durationSection());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimatedChunksScreen(Screen parent, Manager<Animation> animation, Manager<Ease> ease, ConfigManager config, ProgressManager progress) {
|
public AnimatedChunksScreen(Screen parent, ConfigManager config, Animator animator) {
|
||||||
super(Text.of("Animated Chunks Config"));
|
super(Text.of("Animated Chunks Config"));
|
||||||
config.reload();
|
config.reload();
|
||||||
this.progress = progress;
|
this.animator = animator;
|
||||||
this.animation = animation;
|
|
||||||
this.ease = ease;
|
|
||||||
this.config = config;
|
this.config = config;
|
||||||
mainSection.x = mainSection.y = 5;
|
mainSection.x = mainSection.y = 5;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import org.lwjgl.opengl.GL11;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
import me.topchetoeu.animatedchunks.animation.Animator;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.gui.Drawable;
|
import net.minecraft.client.gui.Drawable;
|
||||||
import net.minecraft.client.gui.DrawableHelper;
|
import net.minecraft.client.gui.DrawableHelper;
|
||||||
@ -20,6 +20,7 @@ import net.minecraft.client.render.Tessellator;
|
|||||||
import net.minecraft.client.render.VertexFormat;
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
import net.minecraft.client.render.VertexFormats;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
import net.minecraft.util.math.Quaternion;
|
import net.minecraft.util.math.Quaternion;
|
||||||
import net.minecraft.util.math.Vec3f;
|
import net.minecraft.util.math.Vec3f;
|
||||||
@ -31,8 +32,10 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
void onClick();
|
void onClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClickAction clickAction;
|
|
||||||
public final MinecraftClient client;
|
public final MinecraftClient client;
|
||||||
|
public final Animator animator;
|
||||||
|
|
||||||
|
public ClickAction clickAction;
|
||||||
private boolean clicked = false;
|
private boolean clicked = false;
|
||||||
private boolean rotating = false;
|
private boolean rotating = false;
|
||||||
private boolean focused = false;
|
private boolean focused = false;
|
||||||
@ -158,23 +161,30 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
RenderSystem.enableBlend();
|
RenderSystem.enableBlend();
|
||||||
}
|
}
|
||||||
private void renderChunk(MatrixStack matrices, int x, int y, int n, float delta) {
|
private void renderChunk(MatrixStack matrices, int x, int y, int n, float delta) {
|
||||||
|
duration = animator.getDuration();
|
||||||
|
|
||||||
|
float progress = globalProgress / duration - (float)Math.sqrt(x * x + y * y) / (float)n / 2;
|
||||||
|
if (progress > 1) progress = 1;
|
||||||
|
if (progress <= 0) return;
|
||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
matrices.translate(x * 16 - 8, 0, y * 16 - 8);
|
matrices.translate(x * 16 - 8, 0, y * 16 - 8);
|
||||||
|
|
||||||
// x += n;
|
// x += n;
|
||||||
// y += n;
|
// y += n;
|
||||||
|
|
||||||
float progress = globalProgress / duration - (float)Math.sqrt(x * x + y * y) / (float)n / 2;
|
animator.animate(matrices, progress, new BlockPos(x * 16, 0, y * 16));
|
||||||
if (progress < 0) progress = 0;
|
|
||||||
if (progress > 1) progress = 1;
|
// if (progress < 0) progress = 0;
|
||||||
if (progress < 0.999) {
|
// if (progress > 1) progress = 1;
|
||||||
float _progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
// if (progress < 0.999) {
|
||||||
AnimatedChunks.getInstance().getAnimationManager().getValue().animate(
|
// float _progress = animator.EASES.getValue().ease(progress);
|
||||||
_progress, matrices,
|
// AnimatedChunks.getInstance().getAnimationManager().getValue().animate(
|
||||||
x * 16, 0, y * 16, 0, 0, 0
|
// _progress, matrices,
|
||||||
);
|
// x * 16, 0, y * 16, 0, 0, 0
|
||||||
// matrices.translate(0, 0, 16);
|
// );
|
||||||
}
|
// // matrices.translate(0, 0, 16);
|
||||||
|
// }
|
||||||
matrices.translate(0, 0, 16);
|
matrices.translate(0, 0, 16);
|
||||||
matrices.multiply(rotation);
|
matrices.multiply(rotation);
|
||||||
myFill(matrices, 2, 1, 14, 2, progress, 1, 1, 1);
|
myFill(matrices, 2, 1, 14, 2, progress, 1, 1, 1);
|
||||||
@ -185,7 +195,6 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
matrices.pop();
|
matrices.pop();
|
||||||
}
|
}
|
||||||
private void renderChunks(MatrixStack matrices, float delta, int n) {
|
private void renderChunks(MatrixStack matrices, float delta, int n) {
|
||||||
duration = AnimatedChunks.getInstance().getProgressManager().getDuration();
|
|
||||||
// globalProgress += (lastTime - (lastTime = System.nanoTime())) / -1000000000f;
|
// globalProgress += (lastTime - (lastTime = System.nanoTime())) / -1000000000f;
|
||||||
globalProgress += delta * 0.05f;
|
globalProgress += delta * 0.05f;
|
||||||
matrices.push();
|
matrices.push();
|
||||||
@ -316,16 +325,18 @@ public class ChunkPreview extends DrawableHelper implements Drawable, Element, S
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPreview(int x, int y) {
|
public ChunkPreview(int x, int y, Animator animator) {
|
||||||
this.client = MinecraftClient.getInstance();
|
this.client = MinecraftClient.getInstance();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
this.animator = animator;
|
||||||
}
|
}
|
||||||
public ChunkPreview(int x, int y, int w, int h) {
|
public ChunkPreview(int x, int y, int w, int h, Animator animator) {
|
||||||
this.client = MinecraftClient.getInstance();
|
this.client = MinecraftClient.getInstance();
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.width = w;
|
this.width = w;
|
||||||
this.height = h;
|
this.height = h;
|
||||||
|
this.animator = animator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ import net.minecraft.util.math.BlockPos;
|
|||||||
|
|
||||||
// From flogic's mod
|
// From flogic's mod
|
||||||
@Mixin(ChunkBuilder.BuiltChunk.class)
|
@Mixin(ChunkBuilder.BuiltChunk.class)
|
||||||
abstract class BuiltChunkMixin {
|
public abstract class BuiltChunkMixin {
|
||||||
@Inject(method = "clear", at = @At(value = "TAIL"), cancellable = true)
|
@Inject(method = "clear", at = @At(value = "TAIL"), cancellable = true)
|
||||||
public void clear(CallbackInfo ci) {
|
public void clear(CallbackInfo ci) {
|
||||||
// ci.cancel();
|
// ci.cancel();
|
||||||
// return;
|
// return;
|
||||||
BlockPos origin = ((ChunkBuilder.BuiltChunk)(Object)this).getOrigin();
|
BlockPos origin = ((ChunkBuilder.BuiltChunk)(Object)this).getOrigin();
|
||||||
AnimatedChunks.getInstance().getProgressManager().unload(origin.getX(), 0, origin.getZ());
|
AnimatedChunks.getInstance().animator.unload(origin.getX(), 0, origin.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,6 +11,8 @@ import net.minecraft.client.render.WorldRenderer;
|
|||||||
import net.minecraft.client.render.WorldRenderer.ChunkInfo;
|
import net.minecraft.client.render.WorldRenderer.ChunkInfo;
|
||||||
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
import net.minecraft.client.render.chunk.ChunkBuilder.BuiltChunk;
|
||||||
import net.minecraft.client.util.math.MatrixStack;
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
import net.minecraft.client.util.math.Vector3d;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Matrix4f;
|
import net.minecraft.util.math.Matrix4f;
|
||||||
|
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@ -22,22 +24,17 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
|||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
import it.unimi.dsi.fastutil.objects.ObjectListIterator;
|
||||||
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
import me.topchetoeu.animatedchunks.AnimatedChunks;
|
||||||
import me.topchetoeu.animatedchunks.animation.ProgressManager;
|
|
||||||
|
|
||||||
@Mixin(WorldRenderer.class)
|
@Mixin(WorldRenderer.class)
|
||||||
abstract class WorldRendererMixin {
|
public abstract class WorldRendererMixin {
|
||||||
private long lastTime = System.nanoTime();
|
private long lastTime = System.nanoTime();
|
||||||
|
|
||||||
@Accessor abstract BuiltChunkStorage getChunks();
|
@Accessor abstract BuiltChunkStorage getChunks();
|
||||||
|
|
||||||
private ProgressManager getProgressManager() {
|
|
||||||
return AnimatedChunks.getInstance().getProgressManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Inject(method = "render", at = @At(value = "HEAD"))
|
@Inject(method = "render", at = @At(value = "HEAD"))
|
||||||
private void renderStart(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
|
private void renderStart(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo ci) {
|
||||||
long currTime = System.nanoTime();
|
long currTime = System.nanoTime();
|
||||||
getProgressManager().tick((currTime - lastTime) / 1000000000f);
|
AnimatedChunks.getInstance().animator.tick((currTime - lastTime) / 1000000000f);
|
||||||
lastTime = currTime;
|
lastTime = currTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +48,7 @@ abstract class WorldRendererMixin {
|
|||||||
if (playerY < 0) chunkY--;
|
if (playerY < 0) chunkY--;
|
||||||
if (playerZ < 0) chunkZ--;
|
if (playerZ < 0) chunkZ--;
|
||||||
|
|
||||||
getProgressManager().unloadAllFar((int)((WorldRenderer)(Object)this).getViewDistance(), chunkX, chunkY, chunkZ);
|
AnimatedChunks.getInstance().animator.unloadAllFar((int)((WorldRenderer)(Object)this).getViewDistance(), chunkX, chunkY, chunkZ);
|
||||||
}
|
}
|
||||||
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawElements()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
@Inject(method = "renderLayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gl/VertexBuffer;drawElements()V"), locals=LocalCapture.CAPTURE_FAILHARD)
|
||||||
private void renderChunkBefore(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
private void renderChunkBefore(RenderLayer renderLayer, MatrixStack matrices, double playerX, double playerY, double playerZ, Matrix4f positionMatrix, CallbackInfo ci,
|
||||||
@ -59,28 +56,26 @@ abstract class WorldRendererMixin {
|
|||||||
|
|
||||||
matrices.push();
|
matrices.push();
|
||||||
|
|
||||||
int x = chunk.getOrigin().getX();
|
AnimatedChunks.getInstance().animator.animate(matrices, new BlockPos(chunk.getOrigin().getX(), 0, chunk.getOrigin().getZ()), new Vector3d(playerX, playerY, playerZ));
|
||||||
int y = chunk.getOrigin().getY();
|
|
||||||
int z = chunk.getOrigin().getZ();
|
|
||||||
|
|
||||||
if (getProgressManager().isChunkLoaded(x, 0, z)) {
|
// if (getProgressManager().isChunkLoaded(x, 0, z)) {
|
||||||
float progress = getProgressManager().getChunkProgress(x, 0, z);
|
// float progress = getProgressManager().getChunkProgress(x, 0, z);
|
||||||
|
|
||||||
if (progress < 0.999) {
|
// if (progress < 0.999) {
|
||||||
progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
// progress = AnimatedChunks.getInstance().getEaseManager().getValue().ease(progress);
|
||||||
|
|
||||||
float centerX = (float)playerX - x;
|
// float centerX = (float)playerX - x;
|
||||||
float centerY = (float)playerY - y;
|
// float centerY = (float)playerY - y;
|
||||||
float centerZ = (float)playerZ - z;
|
// float centerZ = (float)playerZ - z;
|
||||||
|
|
||||||
matrices.translate(-centerX, -centerY, -centerZ);
|
// matrices.translate(-centerX, -centerY, -centerZ);
|
||||||
AnimatedChunks.getInstance().getAnimationManager().getValue().animate(progress, matrices, x, y, z, (float)playerX, (float)playerY, (float)playerZ);
|
// AnimatedChunks.getInstance().getAnimationManager().getValue().animate(progress, matrices, x, y, z, (float)playerX, (float)playerY, (float)playerZ);
|
||||||
matrices.translate(centerX, centerY, centerZ);
|
// matrices.translate(centerX, centerY, centerZ);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
matrices.scale(0, 0, 0);
|
// matrices.scale(0, 0, 0);
|
||||||
}
|
// }
|
||||||
|
|
||||||
shader.modelViewMat.set(matrices.peek().getPositionMatrix());
|
shader.modelViewMat.set(matrices.peek().getPositionMatrix());
|
||||||
matrices.pop();
|
matrices.pop();
|
||||||
@ -91,6 +86,6 @@ abstract class WorldRendererMixin {
|
|||||||
boolean _1, ObjectListIterator<?> _2, Shader shader, GlUniform _4, ChunkInfo _6, BuiltChunk chunk) {
|
boolean _1, ObjectListIterator<?> _2, Shader shader, GlUniform _4, ChunkInfo _6, BuiltChunk chunk) {
|
||||||
int x = chunk.getOrigin().getX();
|
int x = chunk.getOrigin().getX();
|
||||||
int z = chunk.getOrigin().getZ();
|
int z = chunk.getOrigin().getZ();
|
||||||
getProgressManager().load(x, 0, z);
|
AnimatedChunks.getInstance().animator.load(x, 0, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
"modmenu": ">=4.0.0"
|
"modmenu": ">=4.0.0"
|
||||||
},
|
},
|
||||||
"breaks": {
|
"breaks": {
|
||||||
"sodium": "*",
|
"sodium": "*"
|
||||||
"iris": "*"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user