添加牛头王的配件

This commit is contained in:
Atsuihsio 2025-03-19 00:47:38 +08:00
parent 15a4091c0e
commit 25067360f6
8 changed files with 7800 additions and 1124 deletions

View file

@ -41,11 +41,14 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
@Override
public void setCustomAnimations(Ntw20Item animatable, long instanceId, AnimationState animationState) {
CoreGeoBone gun = getAnimationProcessor().getBone("bone");
// CoreGeoBone scope = getAnimationProcessor().getBone("scope");
CoreGeoBone l = getAnimationProcessor().getBone("l");
CoreGeoBone r = getAnimationProcessor().getBone("r");
CoreGeoBone action = getAnimationProcessor().getBone("action");
CoreGeoBone lh = getAnimationProcessor().getBone("lh");
CoreGeoBone scope = getAnimationProcessor().getBone("Scope1");
CoreGeoBone scope2 = getAnimationProcessor().getBone("Scope2");
CoreGeoBone scope3 = getAnimationProcessor().getBone("Scope3");
CoreGeoBone cross1 = getAnimationProcessor().getBone("Cross1");
CoreGeoBone cross2 = getAnimationProcessor().getBone("Cross2");
CoreGeoBone cross3 = getAnimationProcessor().getBone("Cross3");
Player player = Minecraft.getInstance().player;
if (player == null) return;
@ -71,14 +74,35 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
double fr = ClientEventHandler.fireRot;
int type = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.SCOPE);
int stockType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.STOCK);
int barrelType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.BARREL);
int gripType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP);
if (isProne(player)) {
l.setRotX(-1.5f);
r.setRotX(-1.5f);
}
float posY = switch (type) {
case 0 -> -0.25f;
case 1 -> -0.24f;
case 2 -> -0.5f;
case 3 -> -0.28f;
default -> 0f;
};
float scaleZ = switch (type) {
case 0, 1 -> 0.5f;
case 2 -> 0.8f;
case 3 -> 0.78f;
default -> 0f;
};
float posZ = switch (type) {
case 0, 1 -> 7f;
case 2 -> 9.8f;
case 3 -> 9.9f;
default -> 0f;
};
gun.setPosX(4.5525f * (float) zp);
gun.setPosY(posY * (float) zp - (float) (0.2f * zpz));
gun.setPosZ(posZ * (float) zp + (float) (0.3f * zpz));
gun.setRotZ((float) (0.05f * zpz));
gun.setScaleZ(1f - (scaleZ * (float) zp));
scope.setScaleZ(1f - (0.6f * (float) zp));
scope2.setScaleZ(1f - (0.8f * (float) zp));
scope3.setScaleZ(1f - (0.5f * (float) zp));
CoreGeoBone shen;
if (zt < 0.5) {
@ -112,18 +136,17 @@ public class Ntw20Model extends GeoModel<Ntw20Item> {
CrossHairOverlay.gunRot = shen.getRotZ();
gun.setPosX(4.54f * (float) zp);
gun.setPosY(-0.47f * (float) zp - (float) (0.2f * zpz));
gun.setPosZ(10.0f * (float) zp + (float) (0.3f * zpz));
gun.setRotZ((float) (0.02f * zpz));
gun.setScaleZ(1f - (0.8f * (float) zp));
// scope.setScaleZ(1f - (0.85f * (float) zp));
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 4.3));
action.setPosZ(3f * (float) ClientEventHandler.actionMove);
lh.setPosZ(-3f * (float) ClientEventHandler.actionMove);
CoreGeoBone l = getAnimationProcessor().getBone("l");
CoreGeoBone r = getAnimationProcessor().getBone("r");
rotXBipod = Mth.lerp(1.5f * times, rotXBipod, isProne(player) ? -90 : 0);
l.setRotX(rotXBipod * Mth.DEG_TO_RAD);
r.setRotX(rotXBipod * Mth.DEG_TO_RAD);
CoreGeoBone root = getAnimationProcessor().getBone("root");
root.setPosX((float) (movePosX + 20 * ClientEventHandler.drawTime + 9.3f * mph));
root.setPosY((float) (swayY + movePosY - 40 * ClientEventHandler.drawTime - 2f * vY));

View file

@ -1,11 +1,13 @@
package com.atsuishio.superbwarfare.client.renderer.item;
import com.atsuishio.superbwarfare.client.AnimationHelper;
import com.atsuishio.superbwarfare.client.ItemModelHelper;
import com.atsuishio.superbwarfare.client.layer.Ntw20Layer;
import com.atsuishio.superbwarfare.client.model.item.Ntw20Model;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.heavy.Ntw20Item;
import com.atsuishio.superbwarfare.tools.GunsTool;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.Minecraft;
@ -85,25 +87,51 @@ public class Ntw20Renderer extends GeoItemRenderer<Ntw20Item> {
ItemStack itemStack = player.getMainHandItem();
if (!itemStack.is(ModTags.Items.GUN)) return;
if (name.equals("rex")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden") || !ClientEventHandler.zoom);
if (name.equals("ironSight")) {
bone.setHidden(GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 0);
}
if (name.equals("jing") || name.equals("action") || name.equals("body") || name.equals("base")) {
if (name.equals("Cross1")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| !ClientEventHandler.zoom
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 1);
}
if (name.equals("Cross2")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| !ClientEventHandler.zoom
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 2);
}
if (name.equals("Cross3")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| !ClientEventHandler.zoom
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 3);
}
if (GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) == 2
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("hidden"))) {
bone.setHidden(!itemStack.getOrCreateTag().getBoolean("HoloHidden") && ClientEventHandler.zoom);
}
if (GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) == 3
&& (name.equals("bone1") || name.equals("zhituiqi") || name.equals("guan") || name.equals("jing") || name.equals("rail") || name.equals("base2") || name.equals("guan7"))) {
bone.setHidden(!itemStack.getOrCreateTag().getBoolean("HoloHidden") && ClientEventHandler.zoom);
}
if (name.equals("flare")) {
if (ClientEventHandler.firePosTimer == 0 || ClientEventHandler.firePosTimer > 0.5) {
if (ClientEventHandler.firePosTimer == 0 || ClientEventHandler.firePosTimer > 0.5 || GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.BARREL) == 2) {
bone.setHidden(true);
} else {
bone.setHidden(false);
bone.setScaleX((float) (0.75 + 0.5 * (Math.random() - 0.5)));
bone.setScaleY((float) (0.75 + 0.5 * (Math.random() - 0.5)));
bone.setScaleX((float) (0.55 + 0.5 * (Math.random() - 0.5)));
bone.setScaleY((float) (0.55 + 0.5 * (Math.random() - 0.5)));
bone.setRotZ((float) (0.5 * (Math.random() - 0.5)));
}
}
ItemModelHelper.handleGunAttachments(bone, itemStack, name);
if (this.transformType.firstPerson() && renderingArms) {
AbstractClientPlayer localPlayer = mc.player;

View file

@ -8,6 +8,7 @@ import com.atsuishio.superbwarfare.init.ModItems;
import com.atsuishio.superbwarfare.init.ModSounds;
import com.atsuishio.superbwarfare.init.ModTags;
import com.atsuishio.superbwarfare.item.gun.GunItem;
import com.atsuishio.superbwarfare.network.ModVariables;
import com.atsuishio.superbwarfare.perk.Perk;
import com.atsuishio.superbwarfare.perk.PerkHelper;
import com.atsuishio.superbwarfare.tools.GunsTool;
@ -20,10 +21,12 @@ import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.Entity;
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.level.Level;
import net.minecraftforge.client.extensions.common.IClientItemExtensions;
import software.bernie.geckolib.animatable.GeoItem;
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
@ -114,12 +117,27 @@ public class Ntw20Item extends GunItem implements GeoItem {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.idle"));
}
private PlayState editPredicate(AnimationState<Ntw20Item> event) {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null) return PlayState.STOP;
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ntw_20.edit"));
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ntw_20.idle"));
}
@Override
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var fireAnimController = new AnimationController<>(this, "fireAnimController", 0, this::fireAnimPredicate);
data.add(fireAnimController);
var idleController = new AnimationController<>(this, "idleController", 4, this::idlePredicate);
data.add(idleController);
var editController = new AnimationController<>(this, "editController", 1, this::editPredicate);
data.add(editController);
}
@Override
@ -127,6 +145,30 @@ public class Ntw20Item extends GunItem implements GeoItem {
return this.cache;
}
@Override
public void inventoryTick(ItemStack stack, Level world, Entity entity, int slot, boolean selected) {
super.inventoryTick(stack, world, entity, slot, selected);
int scopeType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.SCOPE);
int magType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.MAGAZINE);
int customMag = switch (magType) {
case 1 -> 3;
case 2 -> 6;
default -> 0;
};
double customZoom = switch (scopeType) {
case 0, 1 -> 0;
case 2 -> 2.25;
default -> GunsTool.getGunDoubleTag(stack, "CustomZoom", 0);
};
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
GunsTool.setGunDoubleTag(stack, "CustomZoom", customZoom);
GunsTool.setGunIntTag(stack, "CustomMagazine", customMag);
}
public static ItemStack getGunInstance() {
ItemStack stack = new ItemStack(ModItems.NTW_20.get());
GunsTool.initCreativeGun(stack, ModItems.NTW_20.getId().getPath());
@ -163,6 +205,26 @@ public class Ntw20Item extends GunItem implements GeoItem {
return true;
}
@Override
public boolean isCustomizable(ItemStack stack) {
return true;
}
@Override
public boolean hasCustomMagazine(ItemStack stack) {
return true;
}
@Override
public boolean hasCustomScope(ItemStack stack) {
return true;
}
@Override
public boolean hasBipod(ItemStack stack) {
return true;
}
@Override
public int getAvailableFireModes() {
return FireMode.SEMI.flag;

File diff suppressed because it is too large Load diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View file

@ -1,5 +1,6 @@
{
"CustomZoom": 3.75,
"MinZoom": 1.25,
"MaxZoom": 6,
"Spread": 8,
"RecoilX": 0.01,
"RecoilY": 0.038,
@ -8,7 +9,7 @@
"Velocity": 36,
"Magazine": 3,
"BoltActionTime": 37,
"Weight": 10,
"Weight": 13,
"NormalReloadTime": 63,
"EmptyReloadTime": 92,
"BypassesArmor": 1,