Skip to content

Commit

Permalink
完成 1.21 的同步更新
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Jan 22, 2025
1 parent c091df4 commit a92d2ed
Show file tree
Hide file tree
Showing 118 changed files with 6,687 additions and 798 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"values": [
"minecraft:cake",
{
"id": "#forge:cakes",
"required": false
},
{
"id": "#c:cakes",
"required": false
},
{
"id": "#jmc:cakes",
"required": false
},
{
"id": "kawaiidishes:cheese_cake",
"required": false
},
{
"id": "kawaiidishes:honey_cheese_cake",
"required": false
},
{
"id": "kawaiidishes:chocolate_cheese_cake",
"required": false
},
{
"id": "kawaiidishes:piece_of_cake",
"required": false
},
{
"id": "kawaiidishes:piece_of_cheesecake",
"required": false
},
{
"id": "kawaiidishes:piece_of_chocolate_cheesecake",
"required": false
},
{
"id": "kawaiidishes:piece_of_honey_cheesecake",
"required": false
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.tartaricacid.touhoulittlemaid.api;

import com.github.tartaricacid.touhoulittlemaid.block.multiblock.MultiBlockManager;
import com.github.tartaricacid.touhoulittlemaid.client.animation.HardcodedAnimationManger;
import com.github.tartaricacid.touhoulittlemaid.client.overlay.MaidTipsOverlay;
import com.github.tartaricacid.touhoulittlemaid.client.renderer.entity.EntityMaidRenderer;
import com.github.tartaricacid.touhoulittlemaid.client.renderer.entity.GeckoEntityMaidRenderer;
Expand Down Expand Up @@ -103,4 +104,11 @@ default void addAdditionMaidLayer(EntityMaidRenderer renderer, EntityRendererPro
@OnlyIn(Dist.CLIENT)
default void addAdditionGeckoMaidLayer(GeckoEntityMaidRenderer<? extends Mob> renderer, EntityRendererProvider.Context context) {
}

/**
* 添加硬编码的动画
*/
@OnlyIn(Dist.CLIENT)
default void addHardcodeAnimation(HardcodedAnimationManger manger) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.github.tartaricacid.touhoulittlemaid.api.animation;

import com.github.tartaricacid.touhoulittlemaid.client.model.bedrock.BedrockPart;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.geo.animated.AnimatedGeoModel;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.world.entity.LivingEntity;

import javax.annotation.Nullable;
import java.util.HashMap;

public interface ICustomAnimation<T extends LivingEntity> {
/**
* 一个工具类,用来获取指定名称的 BedrockPart
*
* @param models 所有的骨骼
* @param partName 指定名称的骨骼
* @return 如果找不到,那么返回 null
*/
@Nullable
static BedrockPart getPartOrNull(HashMap<String, ? extends IModelRenderer> models, String partName) {
IModelRenderer renderer = models.get(partName);
if (renderer == null) {
return null;
}
return renderer.getModelRenderer();
}

/**
* 旧版模型
* 原版里,全局的旋转是单独独立出来一个方法,比后面的动画部分要早执行
*
* @param entity 实体
* @param poseStack 矩阵,就是改变它来控制全局旋转
* @param ageInTicks 实体的 tick 时间,从 0 开始一直增大
* @param rotationYaw 实体的整体的 Y Rot,单位为角度
* @param partialTicks 插值
*/
default void setupRotations(T entity, PoseStack poseStack, float ageInTicks, float rotationYaw, float partialTicks) {
}

/**
* GeckoLib 版模型
* 原版里,全局的旋转是单独独立出来一个方法,比后面的动画部分要早执行
*
* @param entity 实体
* @param poseStack 矩阵,就是改变它来控制全局旋转
* @param ageInTicks 实体的 tick 时间,从 0 开始一直增大
* @param rotationYaw 实体的整体的 Y Rot,单位为角度
* @param partialTicks 插值
*/
default void setupGeckoRotations(T entity, PoseStack poseStack, float ageInTicks, float rotationYaw, float partialTicks) {
}

/**
* 需要添加的动画(旧版模型)
*
* @param entity 实体
* @param models 所有的骨骼
* @param limbSwing 实体行走的里程,可以理解为汽车的里程表
* @param limbSwingAmount 实体行走的速度,可以理解为汽车的速度表
* @param ageInTicks 实体的 tick 时间,从 0 开始一直增大
* @param netHeadYaw 实体的头部 Y Rot,单位为角度
* @param headPitch 实体的头部 X Rot,单位为角度
*/
default void setRotationAngles(T entity, HashMap<String, ? extends IModelRenderer> models,
float limbSwing, float limbSwingAmount, float ageInTicks,
float netHeadYaw, float headPitch) {
}

/**
* 需要添加的动画(GeckoLib 版模型)
*
* @param entity 实体
* @param model 所有的骨骼
* @param limbSwing 实体行走的里程,可以理解为汽车的里程表
* @param limbSwingAmount 实体行走的速度,可以理解为汽车的速度表
* @param ageInTicks 实体的 tick 时间,从 0 开始一直增大
* @param netHeadYaw 实体的头部 Y Rot,单位为角度
* @param headPitch 实体的头部 X Rot,单位为角度
*/
default void setGeckoRotationAngles(T entity, AnimatedGeoModel model,
float limbSwing, float limbSwingAmount, float ageInTicks,
float netHeadYaw, float headPitch) {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package com.github.tartaricacid.touhoulittlemaid.api.animation;

import com.github.tartaricacid.touhoulittlemaid.client.model.bedrock.BedrockPart;

public interface IModelRenderer {
/**
* Get ModelRenderer's BedrockPart
*
* @return BedrockPart
*/
BedrockPart getModelRenderer();

/**
* Get ModelRenderer's x rotate angle
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ default boolean hasFishingHook() {
return false;
}

default boolean onClimbable() {
return false;
}

// 下方为 Deprecated 方法,仅用于适配旧版本模型,无需 Override

@Deprecated
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.github.tartaricacid.touhoulittlemaid.api.mixin;

public interface IPlayerMixin {
boolean tlmInRemoveVehicleCooldown();
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ default boolean canAttack(EntityMaid maid, LivingEntity target) {
return DefaultMonsterType.canAttack(maid, target, monsterType);
}

/**
* 是否拥有额外攻击方式,用于一些额外增伤的设计
* 比如女仆副手持有灭火器,会额外对下界生物造成二次伤害
*
* @param maid 女仆
* @param target 攻击目标
* @return 是否有额外攻击方式
*/
default boolean hasExtraAttack(EntityMaid maid, Entity target) {
return false;
}

/**
* 执行额外伤害
*
* @param maid 女仆
* @param target 攻击目标
* @return 是否成功造成伤害
*/
default boolean doExtraAttack(EntityMaid maid, Entity target) {
return false;
}

@Override
default MenuProvider getTaskConfigGuiProvider(EntityMaid maid) {
final int entityId = maid.getId();
Expand All @@ -93,14 +116,6 @@ public boolean shouldTriggerClientSideContainerClosingOnOpen() {
};
}

default boolean hasExtraAttack(EntityMaid maid, Entity target) {
return false;
}

default boolean doExtraAttack(EntityMaid maid, Entity target) {
return false;
}

@Override
default boolean enablePanic(EntityMaid maid) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.phys.AABB;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.function.Predicate;

public interface IMaidTask {
/**
* 垂直搜索范围
*/
int VERTICAL_SEARCH_RANGE = 4;

/**
* 模式 ID,用于后续模式的判断,也用于本地化的 key
*
Expand Down Expand Up @@ -182,4 +188,32 @@ public boolean shouldTriggerClientSideContainerClosingOnOpen() {
default MenuProvider getTaskInfoGuiProvider(EntityMaid maid) {
return maid.getMaidBackpackType().getGuiProvider(maid.getId());
}

/**
* 实体搜索范围
* <p>
* 给一些远程攻击的武器提供另一些搜索范围,实现超远视距打击
*
* @param maid 女仆
* @return 实体搜索范围
*/
default AABB searchDimension(EntityMaid maid) {
float radius = this.searchRadius(maid);
if (maid.hasRestriction()) {
return new AABB(maid.getRestrictCenter()).inflate(radius, VERTICAL_SEARCH_RANGE, radius);
} else {
return maid.getBoundingBox().inflate(radius, VERTICAL_SEARCH_RANGE, radius);
}
}

/**
* 实体搜索范围的水平范围值
*
* @param maid 女仆
* @return 实体搜索范围水平范围值
*/
default float searchRadius(EntityMaid maid) {
// 默认依据女仆的工作范围划定搜索范围
return maid.getRestrictRadius();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,47 @@

import com.github.tartaricacid.touhoulittlemaid.entity.passive.EntityMaid;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.behavior.BehaviorUtils;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
import net.neoforged.neoforge.common.ModConfigSpec;

import java.util.List;
import java.util.Optional;

public interface IRangedAttackTask extends IAttackTask {
/**
* 可见性校验工具,来自于 Sensor
*/
TargetingConditions TARGET_CONDITIONS = TargetingConditions.forCombat();

/**
* 寻找第一个可见目标,使用独立的方法,区别于 IAttackTask
*
* @param maid 女仆
* @return 第一个可视对象
*/
static Optional<? extends LivingEntity> findFirstValidAttackTarget(EntityMaid maid) {
if (maid.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).isPresent()) {
List<LivingEntity> list = maid.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES).get();
return list.stream().filter(e -> maid.canAttack(e) && maid.canSee(e)).findAny();
}
return Optional.empty();
}

/**
* 依据配置文件和 TargetingConditions 来检验攻击目标是否符合条件
*
* @param maid 女仆
* @param target 女仆将要攻击的对象
* @param configRange 相关距离的配置文件
* @return 能够攻击
*/
static boolean targetConditionsTest(EntityMaid maid, LivingEntity target, ModConfigSpec.IntValue configRange) {
TARGET_CONDITIONS.range(configRange.get());
return TARGET_CONDITIONS.test(maid, target);
}

/**
* 执行射击动作
*
Expand All @@ -12,4 +51,18 @@ public interface IRangedAttackTask extends IAttackTask {
* @param distanceFactor 距离因素,即弓箭的蓄力值
*/
void performRangedAttack(EntityMaid shooter, LivingEntity target, float distanceFactor);

/**
* 女仆是否能看到敌人
* <p>
* 因为原版默认的攻击识别范围是固定死的 16 格,但是一些远程武器我们希望获得超视距打击
* 通过修改此处来获得更远的攻击距离
*
* @param maid 女仆
* @param target 攻击目标
* @return 是否在可视范围内
*/
default boolean canSee(EntityMaid maid, LivingEntity target) {
return BehaviorUtils.canSee(maid, target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class CustomJsAnimationManger {
@Nullable
public static List<Object> getCustomAnimation(Path rootPath, IModelInfo item) {
List<Object> animations = Lists.newArrayList();
if (item.getAnimation() != null && item.getAnimation().size() > 0) {
if (item.getAnimation() != null && !item.getAnimation().isEmpty()) {
for (ResourceLocation res : item.getAnimation()) {
Object animation = CustomJsAnimationManger.getCustomAnimation(rootPath, res);
if (animation != null) {
Expand All @@ -48,7 +48,7 @@ public static List<Object> getCustomAnimation(Path rootPath, IModelInfo item) {
@Nullable
public static List<Object> getCustomAnimation(ZipFile zipFile, IModelInfo item) {
List<Object> animations = Lists.newArrayList();
if (item.getAnimation() != null && item.getAnimation().size() > 0) {
if (item.getAnimation() != null && !item.getAnimation().isEmpty()) {
for (ResourceLocation res : item.getAnimation()) {
Object animation = CustomJsAnimationManger.getCustomAnimation(zipFile, res);
if (animation != null) {
Expand Down
Loading

0 comments on commit a92d2ed

Please sign in to comment.