优化mp5和aa12渲染和动画

This commit is contained in:
17146 2025-05-29 22:42:38 +08:00 committed by Light_Quanta
parent 45044e9f81
commit 19735fd073
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
2 changed files with 14 additions and 38 deletions

View file

@ -65,7 +65,7 @@ public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
ItemModelHelper.handleGunAttachments(bone, itemStack, name); ItemModelHelper.handleGunAttachments(bone, itemStack, name);
if (renderingArms) { if (renderingArms) {
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, false); AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, false);
} }
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color); super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);

View file

@ -12,7 +12,6 @@ import net.minecraft.client.player.LocalPlayer;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.item.Item; import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import software.bernie.geckolib.animation.*; import software.bernie.geckolib.animation.*;
import software.bernie.geckolib.renderer.GeoItemRenderer; import software.bernie.geckolib.renderer.GeoItemRenderer;
@ -22,9 +21,6 @@ import java.util.function.Supplier;
public class Aa12Item extends GunItem { public class Aa12Item extends GunItem {
public String animationProcedure = "empty";
public static ItemDisplayContext transformType;
public Aa12Item() { public Aa12Item() {
super(new Properties().stacksTo(1).rarity(ModEnumExtensions.getLegendary())); super(new Properties().stacksTo(1).rarity(ModEnumExtensions.getLegendary()));
} }
@ -40,47 +36,27 @@ public class Aa12Item extends GunItem {
ItemStack stack = player.getMainHandItem(); ItemStack stack = player.getMainHandItem();
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP; if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
if (this.animationProcedure.equals("empty")) { if (GunData.from(stack).reload.empty()) {
if (GunData.from(stack).reload.empty()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa_12.reload_empty"));
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa_12.reload_empty"));
}
if (GunData.from(stack).reload.normal()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa_12.reload_normal"));
}
if (player.isSprinting() && player.onGround() && ClientEventHandler.cantSprint == 0 && ClientEventHandler.drawTime < 0.01) {
if (ClientEventHandler.tacticalSprint) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.run_fast"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.run"));
}
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.idle"));
} }
return PlayState.STOP;
}
private PlayState procedurePredicate(AnimationState<Aa12Item> event) { if (GunData.from(stack).reload.normal()) {
if (transformType != null && transformType.firstPerson()) { return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa_12.reload_normal"));
if (!this.animationProcedure.equals("empty") && event.getController().getAnimationState() == AnimationController.State.STOPPED) { }
event.getController().setAnimation(RawAnimation.begin().thenPlay(this.animationProcedure));
if (event.getController().getAnimationState() == AnimationController.State.STOPPED) { if (player.isSprinting() && player.onGround() && ClientEventHandler.cantSprint == 0 && ClientEventHandler.drawTime < 0.01) {
this.animationProcedure = "empty"; if (ClientEventHandler.tacticalSprint) {
event.getController().forceAnimationReset(); return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.run_fast"));
} } else {
} else if (this.animationProcedure.equals("empty")) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.run"));
return PlayState.STOP;
} }
} }
return PlayState.CONTINUE;
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.idle"));
} }
@Override @Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) { public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var procedureController = new AnimationController<>(this, "procedureController", 0, this::procedurePredicate);
data.add(procedureController);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate); var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController); data.add(idleController);
} }