修改发射器渲染
This commit is contained in:
parent
f9f02c3321
commit
99a3f7542f
7 changed files with 42 additions and 29 deletions
|
@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
|
|||
import com.atsuishio.superbwarfare.client.AnimationHelper;
|
||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.M79Item;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -13,9 +12,8 @@ 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;
|
||||
|
||||
public class M79ItemModel extends GeoModel<M79Item> {
|
||||
public class M79ItemModel extends CustomGunModel<M79Item> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(M79Item animatable) {
|
||||
|
@ -33,14 +31,14 @@ public class M79ItemModel extends GeoModel<M79Item> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(M79Item animatable, long instanceId, AnimationState animationState) {
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone shen = getAnimationProcessor().getBone("gun");
|
||||
|
||||
public void setCustomAnimations(M79Item animatable, long instanceId, AnimationState<M79Item> 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;
|
||||
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone shen = getAnimationProcessor().getBone("gun");
|
||||
|
||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
double zt = ClientEventHandler.zoomTime;
|
||||
|
|
|
@ -2,9 +2,8 @@ package com.atsuishio.superbwarfare.client.model.item;
|
|||
|
||||
import com.atsuishio.superbwarfare.Mod;
|
||||
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.GunItem;
|
||||
import com.atsuishio.superbwarfare.data.gun.GunData;
|
||||
import com.atsuishio.superbwarfare.event.ClientEventHandler;
|
||||
import com.atsuishio.superbwarfare.item.gun.launcher.SecondaryCataclysm;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -13,9 +12,8 @@ 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;
|
||||
|
||||
public class SecondaryCataclysmModel extends GeoModel<SecondaryCataclysm> {
|
||||
public class SecondaryCataclysmModel extends CustomGunModel<SecondaryCataclysm> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getAnimationResource(SecondaryCataclysm animatable) {
|
||||
|
@ -33,14 +31,14 @@ public class SecondaryCataclysmModel extends GeoModel<SecondaryCataclysm> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setCustomAnimations(SecondaryCataclysm animatable, long instanceId, AnimationState animationState) {
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone shen = getAnimationProcessor().getBone("shen");
|
||||
|
||||
public void setCustomAnimations(SecondaryCataclysm animatable, long instanceId, AnimationState<SecondaryCataclysm> 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;
|
||||
|
||||
GeoBone gun = getAnimationProcessor().getBone("bone");
|
||||
GeoBone shen = getAnimationProcessor().getBone("shen");
|
||||
|
||||
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
|
||||
double zt = ClientEventHandler.zoomTime;
|
||||
|
|
|
@ -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 M79ItemRenderer extends CustomGunRenderer<M79Item> {
|
||||
|
@ -34,12 +35,12 @@ public class M79ItemRenderer extends CustomGunRenderer<M79Item> {
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.59375, 0.6);
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 0.59375, 0.6);
|
||||
}
|
||||
|
||||
if (renderingArms) {
|
||||
AnimationHelper.renderArms(player, this.transformType, stack, name, bone, this.currentBuffer, type, packedLightIn, true);
|
||||
AnimationHelper.renderArms(player, this.renderPerspective, stack, name, bone, buffer, type, packedLightIn, true);
|
||||
}
|
||||
super.renderRecursively(stack, animatable, bone, type, buffer, bufferIn, isReRender, partialTick, packedLightIn, packedOverlayIn, color);
|
||||
}
|
||||
|
|
|
@ -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 SecondaryCataclysmRenderer extends CustomGunRenderer<SecondaryCataclysm> {
|
||||
|
@ -34,12 +35,12 @@ public class SecondaryCataclysmRenderer extends CustomGunRenderer<SecondaryCatac
|
|||
var player = mc.player;
|
||||
if (player == null) return;
|
||||
ItemStack itemStack = player.getMainHandItem();
|
||||
if (!(itemStack.getItem() instanceof GunItem)) return;
|
||||
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.0375, 0.6);
|
||||
if (itemStack.getItem() instanceof GunItem && GeoItem.getId(itemStack) == this.getInstanceId(animatable)) {
|
||||
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.0375, 0.6);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -17,10 +17,12 @@ import net.minecraft.sounds.SoundEvent;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemDisplayContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Rarity;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import java.util.Optional;
|
||||
|
@ -48,8 +50,10 @@ public class M79Item extends GunItem {
|
|||
if (player == null) return PlayState.STOP;
|
||||
ItemStack stack = player.getMainHandItem();
|
||||
if (!(stack.getItem() instanceof GunItem)) return PlayState.STOP;
|
||||
var data = GunData.from(stack);
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m_79.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
if (data.reload.empty()) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m_79.reload"));
|
||||
}
|
||||
|
|
|
@ -27,12 +27,14 @@ import net.minecraft.world.entity.Entity;
|
|||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.inventory.tooltip.TooltipComponent;
|
||||
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.minecraft.world.level.Level;
|
||||
import net.neoforged.neoforge.capabilities.Capabilities;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import software.bernie.geckolib.animation.*;
|
||||
import software.bernie.geckolib.constant.DataTickets;
|
||||
import software.bernie.geckolib.renderer.GeoItemRenderer;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
@ -84,6 +86,9 @@ public class SecondaryCataclysm extends GunItem implements EnergyStorageItem {
|
|||
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.secondary_cataclysm.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
|
||||
if (data.reload.stage() == 1 && data.reload.prepareLoadTimer.get() > 0) {
|
||||
|
@ -110,6 +115,9 @@ public class SecondaryCataclysm extends GunItem implements EnergyStorageItem {
|
|||
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.secondary_cataclysm.idle"));
|
||||
|
||||
var data = GunData.from(stack);
|
||||
|
||||
if (player.isSprinting() && player.onGround()
|
||||
|
@ -133,6 +141,9 @@ public class SecondaryCataclysm extends GunItem implements EnergyStorageItem {
|
|||
}
|
||||
|
||||
private PlayState meleePredicate(AnimationState<SecondaryCataclysm> event) {
|
||||
if (event.getData(DataTickets.ITEM_RENDER_PERSPECTIVE) != ItemDisplayContext.FIRST_PERSON_RIGHT_HAND)
|
||||
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.secondary_cataclysm.idle"));
|
||||
|
||||
if (ClientEventHandler.gunMelee > 0) {
|
||||
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.secondary_cataclysm.hit"));
|
||||
}
|
||||
|
|
|
@ -66,9 +66,9 @@
|
|||
0
|
||||
],
|
||||
"scale": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
1,
|
||||
1,
|
||||
1
|
||||
]
|
||||
},
|
||||
"gui": {
|
||||
|
|
Loading…
Add table
Reference in a new issue