优化mp5和aa12渲染和动画
This commit is contained in:
parent
45044e9f81
commit
19735fd073
2 changed files with 14 additions and 38 deletions
|
@ -65,7 +65,7 @@ public class Mp5ItemRenderer extends CustomGunRenderer<Mp5Item> {
|
|||
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
|
||||
|
||||
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);
|
||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.client.player.LocalPlayer;
|
|||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
@ -22,9 +21,6 @@ import java.util.function.Supplier;
|
|||
|
||||
public class Aa12Item extends GunItem {
|
||||
|
||||
public String animationProcedure = "empty";
|
||||
public static ItemDisplayContext transformType;
|
||||
|
||||
public Aa12Item() {
|
||||
super(new Properties().stacksTo(1).rarity(ModEnumExtensions.getLegendary()));
|
||||
}
|
||||
|
@ -40,47 +36,27 @@ public class Aa12Item extends GunItem {
|
|||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||
|
||||
if (this.animationProcedure.equals("empty")) {
|
||||
if (GunData.from(stack).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"));
|
||||
if (GunData.from(stack).reload.empty()) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa_12.reload_empty"));
|
||||
}
|
||||
return PlayState.STOP;
|
||||
}
|
||||
|
||||
private PlayState procedurePredicate(AnimationState<Aa12Item> event) {
|
||||
if (transformType != null && transformType.firstPerson()) {
|
||||
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) {
|
||||
this.animationProcedure = "empty";
|
||||
event.getController().forceAnimationReset();
|
||||
}
|
||||
} else if (this.animationProcedure.equals("empty")) {
|
||||
return PlayState.STOP;
|
||||
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 PlayState.CONTINUE;
|
||||
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa_12.idle"));
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
data.add(idleController);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue