Skip to content

Commit

Permalink
完成 1.19.2 的同步
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Aug 27, 2024
1 parent 6ae07c0 commit 22b40bb
Show file tree
Hide file tree
Showing 92 changed files with 2,108 additions and 2,794 deletions.
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ repositories {
maven {
url "https://maven.shedaniel.me/"
}
maven {
url = "https://api.modrinth.com/maven"
}
}

dependencies {
Expand Down Expand Up @@ -165,7 +168,10 @@ dependencies {

runtimeOnly fg.deobf("curse.maven:catalogue-459701:${catalogue_id}")

implementation fg.deobf("curse.maven:timeless-and-classics-zero-1028108:${tacz_id}")
implementation fg.deobf('curse.maven:timeless-and-classics-zero-1028108:5529111-sources-5529576')

implementation fg.deobf("maven.modrinth:simple-hats:1.19.2-0.3.2-forge")
implementation fg.deobf("maven.modrinth:curios:1.19.2-5.1.6.3-forge")

annotationProcessor 'org.spongepowered:mixin:0.8.5:processor'
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false
mod_version=1.1.11
mod_version=1.1.12
forge_version=1.19.2-43.2.0
mc_version=1.19.2
jei_version=11.4.0.286
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.github.tartaricacid.touhoulittlemaid.api.client.gui;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;

/**
* 女仆主界面用,按钮用于渲染文本提示
*/
public interface ITooltipButton {
/**
* 鼠标是否悬浮其上
*/
boolean isTooltipHovered();

/**
* 渲染文本提示
*/
void renderTooltip(PoseStack poseStack, Minecraft mc, int mouseX, int mouseY);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.tartaricacid.touhoulittlemaid.capability;

import com.github.tartaricacid.touhoulittlemaid.api.entity.IMaid;
import com.github.tartaricacid.touhoulittlemaid.client.entity.GeckoMaidEntity;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.Mob;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.CapabilityToken;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@OnlyIn(Dist.CLIENT)
public class GeckoMaidEntityCapabilityProvider<E extends Mob> implements ICapabilityProvider {
public static Capability<GeckoMaidEntity<?>> CAP = CapabilityManager.get(new CapabilityToken<>() {
});
private GeckoMaidEntity<E> instance = null;
private E entity;
private IMaid maid;

public GeckoMaidEntityCapabilityProvider(E mob, IMaid maid) {
this.entity = mob;
this.maid = maid;
}

@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) {
return CAP.orEmpty(cap, LazyOptional.of(this::createCapability).cast()).cast();
}

@Nonnull
private GeckoMaidEntity<E> createCapability() {
if (this.instance == null) {
this.instance = new GeckoMaidEntity<>(this.entity, this.maid);
this.entity = null;
this.maid = null;
}
return this.instance;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.tartaricacid.touhoulittlemaid.client.animation.gecko.condition.*;
import com.github.tartaricacid.touhoulittlemaid.client.entity.GeckoMaidEntity;
import com.github.tartaricacid.touhoulittlemaid.compat.tacz.TacCompat;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.IAnimatable;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.PlayState;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.AnimationBuilder;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.ILoopType;
Expand Down Expand Up @@ -46,18 +45,18 @@ public static AnimationManager getInstance() {
}

@Nonnull
public static <P extends IAnimatable> PlayState playLoopAnimation(AnimationEvent<P> event, String animationName) {
public static PlayState playLoopAnimation(AnimationEvent<?> event, String animationName) {
return playAnimation(event, animationName, ILoopType.EDefaultLoopTypes.LOOP);
}

@Nonnull
private static <P extends IAnimatable> PlayState playAnimation(AnimationEvent<P> event, String animationName, ILoopType loopType) {
private static PlayState playAnimation(AnimationEvent<?> event, String animationName, ILoopType loopType) {
event.getController().setAnimation(new AnimationBuilder().addAnimation(animationName, loopType));
return PlayState.CONTINUE;
}

@Nonnull
private static <P extends IAnimatable> PlayState playAnimation(AnimationEvent<P> event, String animationName) {
private static PlayState playAnimation(AnimationEvent<?> event, String animationName) {
event.getController().setAnimation(new AnimationBuilder().addAnimation(animationName));
return PlayState.CONTINUE;
}
Expand All @@ -66,16 +65,16 @@ public void register(AnimationState state) {
data[state.getPriority()].add(state);
}

public PlayState predicateParallel(AnimationEvent<GeckoMaidEntity> event, String animationName) {
public PlayState predicateParallel(AnimationEvent<?> event, String animationName) {
if (Minecraft.getInstance().isPaused()) {
return PlayState.STOP;
}
return playLoopAnimation(event, animationName);
}

@NotNull
public PlayState predicateMain(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateMain(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -99,8 +98,8 @@ public PlayState predicateMain(AnimationEvent<GeckoMaidEntity> event) {
return PlayState.STOP;
}

public PlayState predicateOffhandHold(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateOffhandHold(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -117,7 +116,7 @@ public PlayState predicateOffhandHold(AnimationEvent<GeckoMaidEntity> event) {
playAnimation(event, "empty", ILoopType.EDefaultLoopTypes.LOOP);
}

ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalHold conditionalHold = ConditionManager.getHoldOffhand(id);
if (conditionalHold != null) {
String name = conditionalHold.doTest(maid, InteractionHand.OFF_HAND);
Expand All @@ -129,8 +128,8 @@ public PlayState predicateOffhandHold(AnimationEvent<GeckoMaidEntity> event) {
return PlayState.STOP;
}

public PlayState predicateMainhandHold(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateMainhandHold(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -152,7 +151,7 @@ public PlayState predicateMainhandHold(AnimationEvent<GeckoMaidEntity> event) {
playAnimation(event, "empty", ILoopType.EDefaultLoopTypes.LOOP);
}

ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalHold conditionalHold = ConditionManager.getHoldMainhand(id);
if (conditionalHold != null) {
String name = conditionalHold.doTest(maid, InteractionHand.MAIN_HAND);
Expand All @@ -172,8 +171,8 @@ private boolean isSameItem(IMaid maid, ItemStack maidItem, InteractionHand hand)
return ItemStack.matches(maidItem, preItem);
}

public PlayState predicateSwing(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateSwing(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -182,7 +181,7 @@ public PlayState predicateSwing(AnimationEvent<GeckoMaidEntity> event) {
// 空动画用于重置 PLAY_ONCE 动画
playAnimation(event, "empty", ILoopType.EDefaultLoopTypes.PLAY_ONCE);
}
ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalSwing conditionalSwing = (maid.asEntity().swingingArm == InteractionHand.MAIN_HAND) ? ConditionManager.getSwingMainhand(id) : ConditionManager.getSwingOffhand(id);
if (conditionalSwing != null) {
String name = conditionalSwing.doTest(maid, maid.asEntity().swingingArm);
Expand All @@ -196,8 +195,8 @@ public PlayState predicateSwing(AnimationEvent<GeckoMaidEntity> event) {
return PlayState.CONTINUE;
}

public PlayState predicateUse(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateUse(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -206,7 +205,7 @@ public PlayState predicateUse(AnimationEvent<GeckoMaidEntity> event) {
playAnimation(event, "empty", ILoopType.EDefaultLoopTypes.PLAY_ONCE);
}
if (maid.asEntity().getUsedItemHand() == InteractionHand.MAIN_HAND) {
ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalUse conditionalUse = ConditionManager.getUseMainhand(id);
if (conditionalUse != null) {
String name = conditionalUse.doTest(maid, InteractionHand.MAIN_HAND);
Expand All @@ -216,7 +215,7 @@ public PlayState predicateUse(AnimationEvent<GeckoMaidEntity> event) {
}
return playAnimation(event, "use_mainhand", ILoopType.EDefaultLoopTypes.LOOP);
} else {
ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalUse conditionalUse = ConditionManager.getUseOffhand(id);
if (conditionalUse != null) {
String name = conditionalUse.doTest(maid, InteractionHand.OFF_HAND);
Expand All @@ -230,8 +229,8 @@ public PlayState predicateUse(AnimationEvent<GeckoMaidEntity> event) {
return PlayState.STOP;
}

public PlayState predicateBeg(AnimationEvent<GeckoMaidEntity> event) {
IMaid maid = event.getAnimatable().getMaid();
public PlayState predicateBeg(AnimationEvent<GeckoMaidEntity<?>> event) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -241,8 +240,8 @@ public PlayState predicateBeg(AnimationEvent<GeckoMaidEntity> event) {
return PlayState.STOP;
}

public PlayState predicateArmor(AnimationEvent<GeckoMaidEntity> event, EquipmentSlot slot) {
IMaid maid = event.getAnimatable().getMaid();
public <T extends Mob> PlayState predicateArmor(AnimationEvent<GeckoMaidEntity<T>> event, EquipmentSlot slot) {
IMaid maid = event.getAnimatableEntity().getMaid();
if (maid == null) {
return PlayState.STOP;
}
Expand All @@ -251,7 +250,7 @@ public PlayState predicateArmor(AnimationEvent<GeckoMaidEntity> event, Equipment
return PlayState.STOP;
}

ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionArmor conditionArmor = ConditionManager.getArmor(id);
if (conditionArmor != null) {
String name = conditionArmor.doTest(maid, slot);
Expand All @@ -260,7 +259,7 @@ public PlayState predicateArmor(AnimationEvent<GeckoMaidEntity> event, Equipment
}
}

ResourceLocation animation = event.getAnimatable().getAnimation();
ResourceLocation animation = event.getAnimatableEntity().getAnimationFileLocation();
String defaultName = slot.getName() + ":default";
if (GeckoLibCache.getInstance().getAnimations().get(animation).animations().containsKey(defaultName)) {
return playAnimation(event, defaultName, ILoopType.EDefaultLoopTypes.LOOP);
Expand All @@ -269,16 +268,16 @@ public PlayState predicateArmor(AnimationEvent<GeckoMaidEntity> event, Equipment
}

@Nullable
public PlayState getVehicleAnimation(AnimationEvent<GeckoMaidEntity> event) {
Mob mob = event.getAnimatable().getMaid().asEntity();
public PlayState getVehicleAnimation(AnimationEvent<GeckoMaidEntity<?>> event) {
Mob mob = event.getAnimatableEntity().getMaid().asEntity();
if (mob == null) {
return null;
}
Entity vehicle = mob.getVehicle();
if (vehicle == null || !vehicle.isAlive()) {
return null;
}
ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalVehicle vehicleCondition = ConditionManager.getVehicle(id);
if (vehicleCondition != null) {
String name = vehicleCondition.doTest(mob);
Expand All @@ -289,8 +288,8 @@ public PlayState getVehicleAnimation(AnimationEvent<GeckoMaidEntity> event) {
return null;
}

public PlayState predicatePassengerAnimation(AnimationEvent<GeckoMaidEntity> event) {
Mob mob = event.getAnimatable().getMaid().asEntity();
public PlayState predicatePassengerAnimation(AnimationEvent<GeckoMaidEntity<?>> event) {
Mob mob = event.getAnimatableEntity().getMaid().asEntity();
if (mob == null) {
return PlayState.STOP;
}
Expand All @@ -299,7 +298,7 @@ public PlayState predicatePassengerAnimation(AnimationEvent<GeckoMaidEntity> eve
return PlayState.STOP;
}

ResourceLocation id = event.getAnimatable().getAnimation();
ResourceLocation id = event.getAnimatableEntity().getAnimationFileLocation();
ConditionalPassenger conditionalPassenger = ConditionManager.getPassenger(id);
if (conditionalPassenger != null) {
String name = conditionalPassenger.doTest(mob);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.tartaricacid.touhoulittlemaid.client.animation.gecko;

import com.github.tartaricacid.touhoulittlemaid.api.entity.IMaid;
import com.github.tartaricacid.touhoulittlemaid.client.entity.GeckoMaidEntity;
import com.github.tartaricacid.touhoulittlemaid.entity.favorability.Type;
import com.github.tartaricacid.touhoulittlemaid.entity.item.EntitySit;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.ILoopType;
Expand Down Expand Up @@ -137,7 +136,7 @@ public static void registerVariables() {
parser.register(new LazyVariable("tlm.has_backpack", MolangUtils.FALSE));
}

public static void setParserValue(AnimationEvent<GeckoMaidEntity> animationEvent, MolangParser parser, EntityModelData data, IMaid maid) {
public static void setParserValue(AnimationEvent<?> animationEvent, MolangParser parser, EntityModelData data, IMaid maid) {
Minecraft mc = Minecraft.getInstance();
if (mc.level == null) {
return;
Expand Down Expand Up @@ -217,12 +216,12 @@ public static void setParserValue(AnimationEvent<GeckoMaidEntity> animationEvent
parser.setValue("tlm.has_backpack", () -> MolangUtils.booleanToFloat(maid.hasBackpack()));
}

private static void register(String animationName, ILoopType loopType, int priority, BiPredicate<IMaid, AnimationEvent<GeckoMaidEntity>> predicate) {
private static void register(String animationName, ILoopType loopType, int priority, BiPredicate<IMaid, AnimationEvent<?>> predicate) {
AnimationManager manager = AnimationManager.getInstance();
manager.register(new AnimationState(animationName, loopType, priority, predicate));
}

private static void register(String animationName, int priority, BiPredicate<IMaid, AnimationEvent<GeckoMaidEntity>> predicate) {
private static void register(String animationName, int priority, BiPredicate<IMaid, AnimationEvent<?>> predicate) {
register(animationName, ILoopType.EDefaultLoopTypes.LOOP, priority, predicate);
}

Expand All @@ -245,7 +244,7 @@ private static double getMaxUseDuration(Mob maid) {
}
}

private static float getYawSpeed(AnimationEvent<GeckoMaidEntity> animationEvent, Mob maid) {
private static float getYawSpeed(AnimationEvent<?> animationEvent, Mob maid) {
double seekTime = animationEvent.getAnimationTick();
return maid.getViewYRot((float) seekTime - maid.getViewYRot((float) seekTime - 0.1f));
}
Expand All @@ -259,7 +258,7 @@ private static float getVerticalSpeed(Mob maid) {
return 20 * (float) (maid.position().y - maid.yo);
}

private static double getEyeCloseState(AnimationEvent<GeckoMaidEntity> animationEvent, Mob maid) {
private static double getEyeCloseState(AnimationEvent<?> animationEvent, Mob maid) {
double remainder = (animationEvent.getAnimationTick() + Math.abs(maid.getUUID().getLeastSignificantBits()) % 10) % 90;
boolean isBlinkTime = 85 < remainder && remainder < 90;
return MolangUtils.booleanToFloat(maid.isSleeping() || isBlinkTime);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.tartaricacid.touhoulittlemaid.client.animation.gecko;

import com.github.tartaricacid.touhoulittlemaid.api.entity.IMaid;
import com.github.tartaricacid.touhoulittlemaid.client.entity.GeckoMaidEntity;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.builder.ILoopType;
import com.github.tartaricacid.touhoulittlemaid.geckolib3.core.event.predicate.AnimationEvent;
import net.minecraft.util.Mth;
Expand All @@ -12,16 +11,16 @@ public class AnimationState {
private final String animationName;
private final ILoopType loopType;
private final int priority;
private final BiPredicate<IMaid, AnimationEvent<GeckoMaidEntity>> predicate;
private final BiPredicate<IMaid, AnimationEvent<?>> predicate;

public AnimationState(String animationName, ILoopType loopType, int priority, BiPredicate<IMaid, AnimationEvent<GeckoMaidEntity>> predicate) {
public AnimationState(String animationName, ILoopType loopType, int priority, BiPredicate<IMaid, AnimationEvent<?>> predicate) {
this.animationName = animationName;
this.loopType = loopType;
this.priority = Mth.clamp(priority, Priority.HIGHEST, Priority.LOWEST);
this.predicate = predicate;
}

public BiPredicate<IMaid, AnimationEvent<GeckoMaidEntity>> getPredicate() {
public BiPredicate<IMaid, AnimationEvent<?>> getPredicate() {
return predicate;
}

Expand Down
Loading

0 comments on commit 22b40bb

Please sign in to comment.