修改部分AR的渲染

This commit is contained in:
17146 2025-06-01 03:34:39 +08:00 committed by Light_Quanta
parent 1eaee64c5f
commit 635750d858
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
9 changed files with 53 additions and 41 deletions

View file

@ -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.rifle.InsidiousItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
@ -35,13 +34,13 @@ public class InsidiousItemModel extends CustomGunModel<InsidiousItem> {
}
@Override
public void setCustomAnimations(InsidiousItem animatable, long instanceId, AnimationState animationState) {
GeoBone gun = getAnimationProcessor().getBone("bone");
public void setCustomAnimations(InsidiousItem animatable, long instanceId, AnimationState<InsidiousItem> 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");
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
double zt = ClientEventHandler.zoomTime;

View file

@ -4,7 +4,6 @@ import com.atsuishio.superbwarfare.Mod;
import com.atsuishio.superbwarfare.client.overlay.CrossHairOverlay;
import com.atsuishio.superbwarfare.data.gun.GunData;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.item.gun.rifle.MarlinItem;
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 MarlinItemModel extends GeoModel<MarlinItem> {
public class MarlinItemModel extends CustomGunModel<MarlinItem> {
@Override
public ResourceLocation getAnimationResource(MarlinItem animatable) {
@ -33,15 +31,15 @@ public class MarlinItemModel extends GeoModel<MarlinItem> {
}
@Override
public void setCustomAnimations(MarlinItem animatable, long instanceId, AnimationState animationState) {
GeoBone gun = getAnimationProcessor().getBone("bone");
GeoBone shen = getAnimationProcessor().getBone("shen");
GeoBone jichui = getAnimationProcessor().getBone("jichui");
public void setCustomAnimations(MarlinItem animatable, long instanceId, AnimationState<MarlinItem> 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");
GeoBone jichui = getAnimationProcessor().getBone("jichui");
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
double zt = ClientEventHandler.zoomTime;

View file

@ -3,9 +3,8 @@ package com.atsuishio.superbwarfare.client.model.item;
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.data.gun.GunData;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.item.gun.rifle.SksItem;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
@ -14,9 +13,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 SksItemModel extends GeoModel<SksItem> {
public class SksItemModel extends CustomGunModel<SksItem> {
@Override
public ResourceLocation getAnimationResource(SksItem animatable) {
@ -34,15 +32,15 @@ public class SksItemModel extends GeoModel<SksItem> {
}
@Override
public void setCustomAnimations(SksItem animatable, long instanceId, AnimationState animationState) {
GeoBone gun = getAnimationProcessor().getBone("bone");
GeoBone bolt = getAnimationProcessor().getBone("bolt");
GeoBone shuan = getAnimationProcessor().getBone("bolt2");
public void setCustomAnimations(SksItem animatable, long instanceId, AnimationState<SksItem> 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 bolt = getAnimationProcessor().getBone("bolt");
GeoBone shuan = getAnimationProcessor().getBone("bolt2");
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getTimer().getRealtimeDeltaTicks(), 0.8);
double zt = ClientEventHandler.zoomTime;

View file

@ -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 InsidiousItemRenderer extends CustomGunRenderer<InsidiousItem> {
@ -34,14 +35,13 @@ public class InsidiousItemRenderer extends CustomGunRenderer<InsidiousItem> {
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, 1, 0.38);
AnimationHelper.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.359325, 40, 0.33f, 255, 0, 0, 255, "insidious", false);
}
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);
}

View file

@ -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 MarlinItemRenderer extends CustomGunRenderer<MarlinItem> {
@ -34,12 +35,12 @@ public class MarlinItemRenderer extends CustomGunRenderer<MarlinItem> {
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, 1.33720625, 0.4);
}
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);
}

View file

@ -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 SksItemRenderer extends CustomGunRenderer<SksItem> {
@ -34,14 +35,13 @@ public class SksItemRenderer extends CustomGunRenderer<SksItem> {
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.handleZoomCrossHair(currentBuffer, renderType, name, stack, bone, buffer, 0, 0.25654375, 20, 2f, 0, 255, 0, 255, "okp_7", false);
AnimationHelper.handleShootFlare(name, stack, itemStack, bone, buffer, packedLightIn, 0, 0, 1.4375, 0.35);
}
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);
}

View file

@ -11,9 +11,11 @@ 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 net.minecraft.world.item.Rarity;
import software.bernie.geckolib.animation.*;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.renderer.GeoItemRenderer;
import java.util.Set;
@ -35,8 +37,10 @@ public class InsidiousItem 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.insidious.idle"));
var data = GunData.from(stack);
if (data.reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.insidious.reload"));
}

View file

@ -11,9 +11,11 @@ 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 net.minecraft.world.item.Rarity;
import software.bernie.geckolib.animation.*;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.renderer.GeoItemRenderer;
import java.util.Set;
@ -35,6 +37,9 @@ public class MarlinItem 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.marlin.idle"));
var data = GunData.from(stack);
if (data.bolt.actionTimer.get() > 0) {
@ -65,6 +70,9 @@ public class MarlinItem 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.marlin.idle"));
var data = GunData.from(stack);
if (player.isSprinting() && player.onGround()

View file

@ -12,10 +12,12 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.Entity;
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 net.minecraft.world.level.Level;
import software.bernie.geckolib.animation.*;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.renderer.GeoItemRenderer;
import javax.annotation.ParametersAreNonnullByDefault;
@ -45,6 +47,8 @@ public class SksItem 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.sks.idle"));
if (GunData.from(stack).reload.empty()) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sks.reload_empty"));