Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API #1199

Closed
wants to merge 6 commits into from
Closed

Add API #1199

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/main/java/github/com/gengyoubo/chanegd/api/ChangedAPI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package github.com.gengyoubo.chanegd.api;

import net.ltxprogrammer.changed.Changed;
import net.ltxprogrammer.changed.entity.variant.TransfurVariant;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

public class ChangedAPI {
/**
* @return will return the latex variant of the current entity.
*/
public static TransfurVariant<?> getEntityLatexVariant(@NotNull LivingEntity entity) {
return TransfurVariant.getEntityVariant(entity);
}
/**
* @return will return the player's latex variant.
*/
public static TransfurVariant<?> getPlayerLatexVariant(@NotNull Player player) {
return getEntityLatexVariant(player);
}
/**
* @param player current player
* @param variant Latex variants that need to be compared
* @return Returns true if the player variant is the same as the latex variant being compared, otherwise it returns false.
*/
public static boolean isPlayerLatexVariantAppointed(@NotNull Player player,@NotNull String variant) {
ResourceKey<?> importVariantKey = ResourceKey.createRegistryKey(Changed.modResource(variant));
TransfurVariant<?> nowVariant = getPlayerLatexVariant(player);
if (nowVariant == null || nowVariant.getRegistryName() == null) {
return false;
}
return Objects.requireNonNull(nowVariant.getRegistryName()).equals(importVariantKey.location());
}
/**
* @return Checks if the player is a latex, returns true if it is otherwise returns false.
*/
public static boolean isPlayerLatex(@NotNull Player player){
return getPlayerLatexVariant(player) != null;
}
}