Add translation amount config option
This commit is contained in:
parent
180e5ead1a
commit
05096f0492
@ -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
|
@Config(name = "smooth-chunks") @Config.Gui.Background("minecraft:textures/block/stone.png") @Getter
|
||||||
public class SmoothChunksConfig implements ConfigData {
|
public class SmoothChunksConfig implements ConfigData {
|
||||||
|
//TODO use localization for comment strings.
|
||||||
@Comment("Duration of the animation in seconds.")
|
@Comment("Duration of the animation in seconds.")
|
||||||
@ConfigEntry.BoundedDiscrete(min = 0, max = 4)
|
|
||||||
double 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.")
|
@Comment("Type of animation for loading chunks.")
|
||||||
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
|
@ConfigEntry.Gui.EnumHandler(option = ConfigEntry.Gui.EnumHandler.EnumDisplayOption.BUTTON)
|
||||||
LoadAnimation loadAnimation = LoadAnimation.UPWARD;
|
LoadAnimation loadAnimation = LoadAnimation.UPWARD;
|
||||||
|
|
||||||
@Comment("Disable animating chunks close to you")
|
@Comment("Disable animating chunks close to you")
|
||||||
boolean disableNearby = true;
|
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 int getTranslationAmount() {
|
||||||
|
return translationAmount / 5;
|
||||||
|
}
|
||||||
}
|
}
|
@ -45,7 +45,7 @@ public final class ChunkAnimationHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
animations.put(chunk, new AnimationController(chunk.getOrigin(), direction, System.currentTimeMillis()));
|
animations.putIfAbsent(chunk, new AnimationController(chunk.getOrigin(), direction, System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateChunk(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
|
public void updateChunk(ChunkBuilder.BuiltChunk chunk, MatrixStack stack) {
|
||||||
@ -69,15 +69,15 @@ public final class ChunkAnimationHandler {
|
|||||||
switch (config.getLoadAnimation()) {
|
switch (config.getLoadAnimation()) {
|
||||||
default:
|
default:
|
||||||
case DOWNWARD:
|
case DOWNWARD:
|
||||||
stack.translate(0, finalPos.getY() - (completion * finalPos.getY()), 0);
|
stack.translate(0, (finalPos.getY() - completion * finalPos.getY()) * config.getTranslationAmount(), 0);
|
||||||
break;
|
break;
|
||||||
case UPWARD:
|
case UPWARD:
|
||||||
stack.translate(0, -finalPos.getY() + (completion * finalPos.getY()), 0);
|
stack.translate(0, (-finalPos.getY() + completion * finalPos.getY()) * config.getTranslationAmount(), 0);
|
||||||
break;
|
break;
|
||||||
case INWARD:
|
case INWARD:
|
||||||
if (controller.getDirection() == null) break;
|
if (controller.getDirection() == null) break;
|
||||||
Vec3i dirVec = controller.getDirection().getVector();
|
Vec3i dirVec = controller.getDirection().getVector();
|
||||||
double mod = -(200 - UtilEasing.easeInOutSine(completion) * 200);
|
double mod = -(200 - UtilEasing.easeInOutSine(completion) * 200) * config.getTranslationAmount();
|
||||||
stack.translate(dirVec.getX() * mod, 0, dirVec.getZ() * mod);
|
stack.translate(dirVec.getX() * mod, 0, dirVec.getZ() * mod);
|
||||||
break;
|
break;
|
||||||
case SCALE:
|
case SCALE:
|
||||||
|
@ -2,5 +2,6 @@
|
|||||||
"text.autoconfig.smooth-chunks.title": "Smooth Chunks Config",
|
"text.autoconfig.smooth-chunks.title": "Smooth Chunks Config",
|
||||||
"text.autoconfig.smooth-chunks.option.loadAnimation": "Load Animation",
|
"text.autoconfig.smooth-chunks.option.loadAnimation": "Load Animation",
|
||||||
"text.autoconfig.smooth-chunks.option.duration": "Duration",
|
"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"
|
"text.autoconfig.smooth-chunks.option.disableNearby": "Disable for Nearby Chunks"
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user