清理mixin
This commit is contained in:
parent
440689c71a
commit
24c8c3c7ae
4 changed files with 0 additions and 97 deletions
|
@ -3,68 +3,21 @@ package com.atsuishio.superbwarfare.client.model.item;
|
|||
import com.atsuishio.superbwarfare.client.molang.MolangVariable;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.mixins.AnimationProcessorAccessor;
|
||||
import com.atsuishio.superbwarfare.mixins.GeoModelAccessor;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.animation.AnimatableManager;
|
||||
import software.bernie.geckolib.animation.AnimationProcessor;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.loading.math.MathParser;
|
||||
import software.bernie.geckolib.loading.math.MolangQueries;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
import software.bernie.geckolib.util.RenderUtil;
|
||||
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
public abstract class CustomGunModel<T extends GunItem & GeoAnimatable> extends GeoModel<T> {
|
||||
|
||||
// TODO 优化这一坨
|
||||
@Override
|
||||
public void setCustomAnimations(T animatable, long instanceId, AnimationState<T> animationState) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
AnimatableManager<T> animatableManager = animatable.getAnimatableInstanceCache().getManagerForId(instanceId);
|
||||
Double currentTick = animationState.getData(DataTickets.TICK);
|
||||
|
||||
if (currentTick == null)
|
||||
currentTick = RenderUtil.getCurrentTick();
|
||||
|
||||
// if (animatableManager.getFirstTickTime() == -1)
|
||||
// animatableManager.startedAt(currentTick + mc.getFrameTime());
|
||||
|
||||
double currentFrameTime = currentTick - animatableManager.getFirstTickTime();
|
||||
boolean isReRender = !animatableManager.isFirstTick() && currentFrameTime == animatableManager.getLastUpdateTime();
|
||||
|
||||
if (isReRender && instanceId == ((GeoModelAccessor) this).getLastRenderedInstance())
|
||||
return;
|
||||
|
||||
if (!mc.isPaused() || animatable.shouldPlayAnimsWhileGamePaused()) {
|
||||
animatableManager.updatedAt(currentFrameTime);
|
||||
|
||||
double lastUpdateTime = animatableManager.getLastUpdateTime();
|
||||
((GeoModelAccessor) this).setAnimTime(((GeoModelAccessor) this).getAnimTime() + lastUpdateTime - ((GeoModelAccessor) this).getLastGameTickTime());
|
||||
((GeoModelAccessor) this).setLastGameTickTime(lastUpdateTime);
|
||||
}
|
||||
|
||||
animationState.animationTick = ((GeoModelAccessor) this).getAnimTime();
|
||||
((GeoModelAccessor) this).setLastRenderedInstance(instanceId);
|
||||
AnimationProcessor<T> processor = getAnimationProcessor();
|
||||
|
||||
var model = ((AnimationProcessorAccessor<T>) processor).getModel();
|
||||
if (model instanceof CustomGunModel<T> customGunModel) {
|
||||
customGunModel.applyCustomMolangQueries(animationState, ((GeoModelAccessor) this).getAnimTime());
|
||||
}
|
||||
|
||||
if (!processor.getRegisteredBones().isEmpty())
|
||||
processor.tickAnimation(animatable, this, animatableManager, ((GeoModelAccessor) this).getAnimTime(), animationState, crashIfBoneMissing());
|
||||
|
||||
setCustomAnimations(animatable, instanceId, animationState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyMolangQueries(AnimationState<T> animationState, double animTime) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
@ -76,15 +29,8 @@ public abstract class CustomGunModel<T extends GunItem & GeoAnimatable> extends
|
|||
set(MolangQueries.TIME_OF_DAY, () -> mc.level.getDayTime() / 24000f);
|
||||
set(MolangQueries.MOON_PHASE, mc.level::getMoonPhase);
|
||||
}
|
||||
}
|
||||
|
||||
public void applyCustomMolangQueries(AnimationState<T> animationState, double animTime) {
|
||||
this.applyMolangQueries(animationState, animTime);
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
||||
// GunData
|
||||
|
||||
var player = mc.player;
|
||||
if (player == null) {
|
||||
resetQueryValue();
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import software.bernie.geckolib.animatable.GeoAnimatable;
|
||||
import software.bernie.geckolib.animation.AnimationProcessor;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
@Mixin(AnimationProcessor.class)
|
||||
public interface AnimationProcessorAccessor<T extends GeoAnimatable> {
|
||||
|
||||
@Accessor(value = "model", remap = false)
|
||||
GeoModel<T> getModel();
|
||||
}
|
|
@ -1,27 +0,0 @@
|
|||
package com.atsuishio.superbwarfare.mixins;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
@Mixin(GeoModel.class)
|
||||
public interface GeoModelAccessor {
|
||||
|
||||
@Accessor(value = "animTime", remap = false)
|
||||
double getAnimTime();
|
||||
|
||||
@Accessor(value = "animTime", remap = false)
|
||||
void setAnimTime(double animTime);
|
||||
|
||||
@Accessor(value = "lastGameTickTime", remap = false)
|
||||
double getLastGameTickTime();
|
||||
|
||||
@Accessor(value = "lastGameTickTime", remap = false)
|
||||
void setLastGameTickTime(double lastGameTickTime);
|
||||
|
||||
@Accessor(value = "lastRenderedInstance", remap = false)
|
||||
long getLastRenderedInstance();
|
||||
|
||||
@Accessor(value = "lastRenderedInstance", remap = false)
|
||||
void setLastRenderedInstance(long lastRenderedInstance);
|
||||
}
|
|
@ -4,12 +4,10 @@
|
|||
"compatibilityLevel": "JAVA_21",
|
||||
"refmap": "mixins.superbwarfare.refmap.json",
|
||||
"mixins": [
|
||||
"AnimationProcessorAccessor",
|
||||
"BeastMixin",
|
||||
"ClientboundSetPassengersPacketMixin",
|
||||
"EntityMixin",
|
||||
"FishingHookMixin",
|
||||
"GeoModelAccessor",
|
||||
"LivingEntityMixin",
|
||||
"PlayerMixin",
|
||||
"VillagerMixin"
|
||||
|
|
Loading…
Add table
Reference in a new issue