90 lines
3.3 KiB
Java
90 lines
3.3 KiB
Java
/*
|
|
* Copyright 2025-2026 R3944Realms
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package top.r3944realms.eroticdungeongame.content.animation;
|
|
|
|
import io.zershyan.sccore.animation.AnimationApi;
|
|
import io.zershyan.sccore.animation.helper.AnimationHelper;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.player.Player;
|
|
import org.jetbrains.annotations.NotNull;
|
|
import org.jetbrains.annotations.Nullable;
|
|
import top.r3944realms.eroticdungeongame.EroticDungeon;
|
|
|
|
import java.util.Objects;
|
|
|
|
public interface IEDGAnimation {
|
|
ResourceLocation LAYER = EroticDungeon.rl("top_height_layer");
|
|
ResourceLocation getBaseId();
|
|
Class<?> getBlockClass();
|
|
@NotNull
|
|
default ResourceLocation getDefaultRL() {
|
|
return getBaseId().withSuffix("01");
|
|
}
|
|
|
|
@NotNull
|
|
default ResourceLocation getVarietyRL(int varNumber) {
|
|
return getBaseId().withSuffix(String.format("%02d", Math.max(1, Math.min(99, varNumber))));
|
|
}
|
|
|
|
static @NotNull ResourceLocation getDefaultRLStatic(@NotNull IEDGAnimation animation) {
|
|
return animation.getDefaultRL();
|
|
}
|
|
|
|
static @NotNull ResourceLocation getVarietyRLStatic(@NotNull IEDGAnimation animation, int varNumber) {
|
|
return animation.getVarietyRL(varNumber);
|
|
}
|
|
|
|
|
|
default void play(Player player) {
|
|
if (player != null && !player.level().isClientSide) {
|
|
AnimationHelper helper = AnimationApi.getHelper(player);
|
|
helper.playAnimation(IEDGAnimation.LAYER, getBaseId().withSuffix("01"));
|
|
|
|
}
|
|
}
|
|
default void play(Player player, int varNumber) {
|
|
if (player != null && !player.level().isClientSide) {
|
|
AnimationHelper helper = AnimationApi.getHelper(player);
|
|
helper.playAnimation(IEDGAnimation.LAYER, getBaseId().withSuffix(String.format("%02d", Math.max(1, Math.min(99, varNumber)))));
|
|
}
|
|
}
|
|
|
|
@Nullable
|
|
static ResourceLocation getPlayingAnimation(Player player) {
|
|
if (player != null && !player.level().isClientSide) {
|
|
AnimationHelper helper = AnimationApi.getHelper(player);
|
|
return helper.getAnimationPlaying(IEDGAnimation.LAYER);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static boolean isPlayerAnimation(Player player, @NotNull IEDGAnimation animation) {
|
|
return Objects.equals(getPlayingAnimation(player), animation.getDefaultRL());
|
|
}
|
|
|
|
static boolean isPlayerAnimation(Player player, @NotNull IEDGAnimation animation, int varNumber) {
|
|
return Objects.equals(getPlayingAnimation(player), animation.getVarietyRL(varNumber));
|
|
}
|
|
|
|
static void stop(Player player) {
|
|
if (player != null && !player.level().isClientSide) {
|
|
AnimationHelper helper = AnimationApi.getHelper(player);
|
|
helper.removeAnimation(IEDGAnimation.LAYER);
|
|
}
|
|
}
|
|
}
|