尝试实现海月权杖渲染分离
This commit is contained in:
parent
21faa4c0f1
commit
92851546ea
4 changed files with 19 additions and 11 deletions
|
@ -2,7 +2,6 @@ package com.atsuishio.superbwarfare.client.model.item;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.handgun.AureliaSceptre;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -11,11 +10,10 @@ import net.minecraft.world.entity.player.Player;
|
|||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animation.AnimationState;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
import software.bernie.geckolib.model.GeoModel;
|
||||
|
||||
import static com.atsuishio.superbwarfare.event.ClientEventHandler.*;
|
||||
|
||||
public class AureliaSceptreModel extends GeoModel<AureliaSceptre> {
|
||||
public class AureliaSceptreModel extends CustomGunModel<AureliaSceptre> {
|
||||
|
||||
public static float fireRotY = 0f;
|
||||
public static float fireRotZ = 0f;
|
||||
|
@ -37,11 +35,11 @@ public class AureliaSceptreModel extends GeoModel<AureliaSceptre> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(AureliaSceptre animatable, long instanceId, AnimationState animationState) {
|
||||
public void setCustomAnimations(AureliaSceptre animatable, long instanceId, AnimationState<AureliaSceptre> animationState) {
|
||||
Player player = Minecraft.getInstance().player;
|
||||
if (player == null) return;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return;
|
||||
if (shouldCancelRender(stack, animationState)) return;
|
||||
|
||||
float times = 0.2f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
|
||||
|
@ -51,7 +49,6 @@ public class AureliaSceptreModel extends GeoModel<AureliaSceptre> {
|
|||
|
||||
firePosMove = Mth.lerp((holdFire ? 5 : 2) * times, firePosMove, holdFire ? 1 : 0);
|
||||
|
||||
|
||||
rootLeftHand.setPosX((float) (-movePosX + 20 * drawTime + 9.3f * movePosHorizon));
|
||||
rootLeftHand.setPosY((float) (swayY - movePosY - 40 * drawTime - 2f * velocityY + 1 * firePosMove));
|
||||
rootLeftHand.setPosZ(-6 * firePosMove);
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import software.bernie.geckolib.animatable.GeoItem;
|
||||
import software.bernie.geckolib.cache.object.GeoBone;
|
||||
|
||||
public class AureliaSceptreRenderer extends CustomGunRenderer<AureliaSceptre> {
|
||||
|
@ -34,9 +35,9 @@ public class AureliaSceptreRenderer extends CustomGunRenderer<AureliaSceptre> {
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.3022, 0.3);
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, false);
|
||||
|
|
|
@ -17,11 +17,13 @@ import net.minecraft.resources.ResourceLocation;
|
|||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.TooltipFlag;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.api.distmarker.OnlyIn;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
@ -57,7 +59,8 @@ public class AureliaSceptre extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aurelia_sceptre.idle"));
|
||||
|
||||
if (player.isSprinting() && player.onGround()
|
||||
&& ClientEventHandler.cantSprint == 0
|
||||
|
@ -73,17 +76,22 @@ public class AureliaSceptre extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem gunItem)) return PlayState.STOP;
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aurelia_sceptre.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
|
||||
if (ClientEventHandler.holdFire && gunItem.canShoot(data) && !data.overHeat.get()) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aurelia_sceptre.fire"));
|
||||
}
|
||||
|
||||
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aurelia_sceptre.idle"));
|
||||
}
|
||||
|
||||
private PlayState meleePredicate(AnimationState<AureliaSceptre> event) {
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aurelia_sceptre.idle"));
|
||||
|
||||
if (ClientEventHandler.gunMelee > 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aurelia_sceptre.hit"));
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ public class M60Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m_60.idle"));
|
||||
|
||||
if (ClientEventHandler.firePosTimer > 0 && ClientEventHandler.firePosTimer < 0.45) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m_60.fire"));
|
||||
|
|
Loading…
Add table
Reference in a new issue