添加HK416的配件适配

This commit is contained in:
Atsuihsio 2024-10-31 02:00:54 +08:00
parent 41dd80747c
commit 8b2492ff23
34 changed files with 20586 additions and 7939 deletions

View file

@ -1,4 +1,4 @@
// 1.20.1 2024-10-25T16:43:38.148877 Tags for minecraft:item mod id superbwarfare
// 1.20.1 2024-10-30T03:13:00.7790602 Tags for minecraft:item mod id superbwarfare
cf8d49a8d2872286d1a9c3d4a7e1c2b7690db0b8 data/forge/tags/items/dusts.json
0fa06c2ff83bf09797e3ddff90f62d1124e645b4 data/forge/tags/items/dusts/coal_coke.json
295ddf906b7133a0558d03e9a60eea18281fe430 data/forge/tags/items/dusts/iron.json
@ -27,12 +27,12 @@ af6fd64b4a685c353f243763db268f7b2304c009 data/forge/tags/items/storage_blocks/le
3743c2790deca7e779d3e4b82f092de39b446988 data/forge/tags/items/storage_blocks/steel.json
144e54d908121dee498b2ebba3b24b09fd6f18d9 data/forge/tags/items/storage_blocks/tungsten.json
4d4dfd25a2a749e000e1bb742c2f984d4e094e5d data/superbwarfare/tags/items/cannot_reload.json
ecfe91ca11cdcac5134558e08c51d5736e577f5b data/superbwarfare/tags/items/can_apply_barrel.json
56f03b913ace71b71b3e927ff55af1819371ca13 data/superbwarfare/tags/items/can_apply_grip.json
ecfe91ca11cdcac5134558e08c51d5736e577f5b data/superbwarfare/tags/items/can_apply_magazine.json
ecfe91ca11cdcac5134558e08c51d5736e577f5b data/superbwarfare/tags/items/can_apply_scope.json
ecfe91ca11cdcac5134558e08c51d5736e577f5b data/superbwarfare/tags/items/can_apply_stock.json
ecfe91ca11cdcac5134558e08c51d5736e577f5b data/superbwarfare/tags/items/can_custom_gun.json
4076a1feed311ef566e890e64f70c1c79a8feb49 data/superbwarfare/tags/items/can_apply_barrel.json
7b922f49ed3e2e2489a998b76f31ba0369e2cee0 data/superbwarfare/tags/items/can_apply_grip.json
4076a1feed311ef566e890e64f70c1c79a8feb49 data/superbwarfare/tags/items/can_apply_magazine.json
4076a1feed311ef566e890e64f70c1c79a8feb49 data/superbwarfare/tags/items/can_apply_scope.json
4076a1feed311ef566e890e64f70c1c79a8feb49 data/superbwarfare/tags/items/can_apply_stock.json
4076a1feed311ef566e890e64f70c1c79a8feb49 data/superbwarfare/tags/items/can_custom_gun.json
dff9ff6d6637951191906cb55a210ae5a3ad5cd6 data/superbwarfare/tags/items/extra_one_ammo.json
52598e22974c8da0d2852defe4c9005e1d67744b data/superbwarfare/tags/items/gun.json
62eb408544731ce4cfcd119d8a6cc74731189ac0 data/superbwarfare/tags/items/handgun.json

View file

@ -2,6 +2,7 @@
"values": [
"superbwarfare:ak_12",
"superbwarfare:ak_47",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -1,6 +1,7 @@
{
"values": [
"superbwarfare:ak_12",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -2,6 +2,7 @@
"values": [
"superbwarfare:ak_12",
"superbwarfare:ak_47",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -2,6 +2,7 @@
"values": [
"superbwarfare:ak_12",
"superbwarfare:ak_47",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -2,6 +2,7 @@
"values": [
"superbwarfare:ak_12",
"superbwarfare:ak_47",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -2,6 +2,7 @@
"values": [
"superbwarfare:ak_12",
"superbwarfare:ak_47",
"superbwarfare:m_4"
"superbwarfare:m_4",
"superbwarfare:hk_416"
]
}

View file

@ -19,6 +19,8 @@ import static net.mcreator.superbwarfare.event.PlayerEventHandler.isProne;
public class AK12ItemModel extends GeoModel<AK12Item> {
public static float rotXBipod = 0f;
@Override
public ResourceLocation getAnimationResource(AK12Item animatable) {
return ModUtils.loc("animations/ak12.animation.json");
@ -68,6 +70,7 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
double fr = ClientEventHandler.fireRot;
int type = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.SCOPE);
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1.6);
float posY = switch (type) {
case 0 -> 0.781f;
@ -126,10 +129,9 @@ public class AK12ItemModel extends GeoModel<AK12Item> {
CoreGeoBone l = getAnimationProcessor().getBone("l");
CoreGeoBone r = getAnimationProcessor().getBone("r");
if (isProne(player)) {
l.setRotX(-90 * Mth.DEG_TO_RAD);
r.setRotX(-90 * Mth.DEG_TO_RAD);
}
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");

View file

@ -1,10 +1,11 @@
package net.mcreator.superbwarfare.client.model.item;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.client.AnimationHelper;
import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item;
import net.mcreator.superbwarfare.client.AnimationHelper;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
@ -14,7 +15,11 @@ import software.bernie.geckolib.core.animatable.model.CoreGeoBone;
import software.bernie.geckolib.core.animation.AnimationState;
import software.bernie.geckolib.model.GeoModel;
import static net.mcreator.superbwarfare.event.PlayerEventHandler.isProne;
public class Hk416ItemModel extends GeoModel<Hk416Item> {
public static float rotXBipod = 0f;
@Override
public ResourceLocation getAnimationResource(Hk416Item animatable) {
return new ResourceLocation(ModUtils.MODID, "animations/hk416.animation.json");
@ -34,7 +39,12 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
public void setCustomAnimations(Hk416Item animatable, long instanceId, AnimationState animationState) {
CoreGeoBone gun = getAnimationProcessor().getBone("bone");
CoreGeoBone shen = getAnimationProcessor().getBone("shen");
CoreGeoBone scope = getAnimationProcessor().getBone("eotech");
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;
@ -58,12 +68,36 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
double fp = ClientEventHandler.firePos;
double fr = ClientEventHandler.fireRot;
gun.setPosX(3.34f * (float) zp);
gun.setPosY(0.54f * (float) zp - (float) (0.2f * zpz));
gun.setPosZ(2.5f * (float) zp + (float) (0.3f * zpz));
gun.setRotZ((float) (0.05f * zpz));
int type = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.SCOPE);
float times = 0.6f * (float) Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1.6);
scope.setScaleZ(1f - (0.7f * (float) zp));
float posY = switch (type) {
case 0 -> 1.04f;
case 1 -> 0.52f;
case 2 -> 0.385f;
case 3 -> 0.46f;
default -> 0f;
};
float scaleZ = switch (type) {
case 2 -> 0.8f;
case 3 -> 0.78f;
default -> 0f;
};
float posZ = switch (type) {
case 0, 1 -> 3.8f;
case 2 -> 7.4f;
case 3 -> 6.8f;
default -> 0f;
};
gun.setPosX(3.3055f * (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));
stack.getOrCreateTag().putBoolean("HoloHidden", !(gun.getPosX() > 3.1));
@ -81,8 +115,18 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
shen.setRotY((float) (shen.getRotY() * (1 - 0.9 * zt)));
shen.setRotZ((float) (shen.getRotZ() * (1 - 0.9 * zt)));
cross1.setPosY(-0.75f * (float) fpz);
cross2.setPosY(-0.7f * (float) fpz);
cross3.setPosY(-0.2f * (float) fpz);
shen.setPosX(0.2f * (float) (ClientEventHandler.recoilHorizon * (0.5 + 0.4 * ClientEventHandler.fireSpread)));
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));
@ -93,8 +137,8 @@ public class Hk416ItemModel extends GeoModel<Hk416Item> {
CoreGeoBone camera = getAnimationProcessor().getBone("camera");
CoreGeoBone main = getAnimationProcessor().getBone("0");
float numR = (float) (1 - 0.88 * zt);
float numP = (float) (1 - 0.78 * zt);
float numR = (float) (1 - 0.985 * zt);
float numP = (float) (1 - 0.92 * zt);
if (stack.getOrCreateTag().getInt("gun_reloading_time") > 0) {
main.setRotX(numR * main.getRotX());

View file

@ -21,6 +21,8 @@ public class M4ItemModel extends GeoModel<M4Item> {
public static float posYAlt = 0.5625f;
public static float scaleZAlt = 0.88f;
public static float posZAlt = 7.6f;
public static float rotXSight = 0f;
public static float rotXBipod = 0f;
@Override
public ResourceLocation getAnimationResource(M4Item animatable) {
@ -80,6 +82,7 @@ public class M4ItemModel extends GeoModel<M4Item> {
posYAlt = Mth.lerp(times, posYAlt, stack.getOrCreateTag().getBoolean("ScopeAlt")? -0.6875f : 0.5625f);
scaleZAlt = Mth.lerp(times, scaleZAlt, stack.getOrCreateTag().getBoolean("ScopeAlt")? 0.4f : 0.88f);
posZAlt = Mth.lerp(times, posZAlt, stack.getOrCreateTag().getBoolean("ScopeAlt")? 5.5f : 7.6f);
rotXSight = Mth.lerp(1.5f * times, rotXSight, type == 0 ? 0 : 90);
float posY = switch (type) {
case 0 -> 0.65f;
@ -103,8 +106,8 @@ public class M4ItemModel extends GeoModel<M4Item> {
default -> 0f;
};
sight1fold.setRotX((type == 0 ? 0 : 90) * Mth.DEG_TO_RAD);
sight2fold.setRotX((type == 0 ? 0 : 90) * Mth.DEG_TO_RAD);
sight1fold.setRotX(rotXSight * Mth.DEG_TO_RAD);
sight2fold.setRotX(rotXSight * Mth.DEG_TO_RAD);
gun.setPosX(2.935f * (float) zp);
gun.setPosY(posY * (float) zp - (float) (0.2f * zpz));
@ -143,10 +146,9 @@ public class M4ItemModel extends GeoModel<M4Item> {
CoreGeoBone l = getAnimationProcessor().getBone("l");
CoreGeoBone r = getAnimationProcessor().getBone("r");
if (isProne(player)) {
l.setRotX(-90 * Mth.DEG_TO_RAD);
r.setRotX(-90 * Mth.DEG_TO_RAD);
}
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));

View file

@ -2,10 +2,12 @@ package net.mcreator.superbwarfare.client.renderer.item;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.mcreator.superbwarfare.client.AnimationHelper;
import net.mcreator.superbwarfare.client.ItemModelHelper;
import net.mcreator.superbwarfare.client.layer.Hk416Layer;
import net.mcreator.superbwarfare.client.model.item.Hk416ItemModel;
import net.mcreator.superbwarfare.item.gun.rifle.Hk416Item;
import net.mcreator.superbwarfare.client.AnimationHelper;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;
@ -94,26 +96,61 @@ public class Hk416ItemRenderer extends GeoItemRenderer<Hk416Item> {
}
}
if (name.equals("holo")) {
Player player = Minecraft.getInstance().player;
ItemStack itemStack = null;
Player player = mc.player;
if (player != null) {
itemStack = player.getMainHandItem();
ItemStack itemStack = player.getMainHandItem();
if (name.equals("Cross1")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 1);
}
if (player != null) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden") || GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS);
if (name.equals("Cross2")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 2);
}
if (name.equals("Cross3")) {
bone.setHidden(itemStack.getOrCreateTag().getBoolean("HoloHidden")
|| GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) != GLFW.GLFW_PRESS
|| GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) != 3);
}
if (GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) == 2
&& (name.equals("hidden"))) {
bone.setHidden(!itemStack.getOrCreateTag().getBoolean("HoloHidden") && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS);
}
if (GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.SCOPE) == 3
&& (name.equals("jing") || name.equals("Barrel") || name.equals("yugu") || name.equals("qiangguan"))) {
bone.setHidden(!itemStack.getOrCreateTag().getBoolean("HoloHidden") && GLFW.glfwGetMouseButton(Minecraft.getInstance().getWindow().getWindow(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS);
}
if (name.equals("flare")) {
if (itemStack.getOrCreateTag().getDouble("flash_time") == 0 || GunsTool.getAttachmentType(itemStack, GunsTool.AttachmentType.BARREL) == 2) {
bone.setHidden(true);
} else {
bone.setHidden(false);
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 player = mc.player;
AbstractClientPlayer localPlayer = mc.player;
if (player == null) {
if (localPlayer == null) {
return;
}
PlayerRenderer playerRenderer = (PlayerRenderer) mc.getEntityRenderDispatcher().getRenderer(player);
PlayerRenderer playerRenderer = (PlayerRenderer) mc.getEntityRenderDispatcher().getRenderer(localPlayer);
PlayerModel<AbstractClientPlayer> model = playerRenderer.getModel();
stack.pushPose();
RenderUtils.translateMatrixToBone(stack, bone);
@ -121,7 +158,7 @@ public class Hk416ItemRenderer extends GeoItemRenderer<Hk416Item> {
RenderUtils.rotateMatrixAroundBone(stack, bone);
RenderUtils.scaleMatrixForBone(stack, bone);
RenderUtils.translateAwayFromPivotPoint(stack, bone);
ResourceLocation loc = player.getSkinTextureLocation();
ResourceLocation loc = localPlayer.getSkinTextureLocation();
VertexConsumer armBuilder = this.currentBuffer.getBuffer(RenderType.entitySolid(loc));
VertexConsumer sleeveBuilder = this.currentBuffer.getBuffer(RenderType.entityTranslucent(loc));
if (name.equals("Lefthand")) {

View file

@ -112,17 +112,17 @@ public class ModItemTagProvider extends ItemTagsProvider {
this.tag(ModTags.Items.MILITARY_ARMOR).add(ModItems.RU_CHEST_6B43.get(), ModItems.US_CHEST_IOTV.get());
this.tag(ModTags.Items.CAN_CUSTOM_GUN).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_CUSTOM_GUN).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
this.tag(ModTags.Items.CAN_APPLY_BARREL).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_APPLY_BARREL).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
this.tag(ModTags.Items.CAN_APPLY_GRIP).add(ModItems.AK_12.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_APPLY_GRIP).add(ModItems.AK_12.get(), ModItems.M_4.get(), ModItems.HK_416.get());
this.tag(ModTags.Items.CAN_APPLY_SCOPE).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_APPLY_SCOPE).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
this.tag(ModTags.Items.CAN_APPLY_MAGAZINE).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_APPLY_MAGAZINE).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
this.tag(ModTags.Items.CAN_APPLY_STOCK).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get());
this.tag(ModTags.Items.CAN_APPLY_STOCK).add(ModItems.AK_12.get(), ModItems.AK_47.get(), ModItems.M_4.get(), ModItems.HK_416.get());
}

View file

@ -186,12 +186,6 @@ public class ClientEventHandler {
double spread = stack.is(ModTags.Items.SHOTGUN) || stack.is(ModItems.MINIGUN.get()) ? 1.2 * zoomSpread * (basicDev + 0.2 * (walk + sprint + crouching + prone + jump + ride) + fireSpread) : zoomSpread * (0.7 * basicDev + walk + sprint + crouching + prone + jump + ride + 0.8 * fireSpread);
// if (gunSpread < spread) {
// gunSpread += 0.07 * Math.pow(spread - gunSpread, 2) * times;
// } else {
// gunSpread -= 0.07 * Math.pow(spread - gunSpread, 2) * times;
// }
gunSpread = Mth.lerp(0.07 * times, gunSpread, spread);
// 开火部分
@ -510,7 +504,7 @@ public class ClientEventHandler {
}
private static void handleWeaponFire(ViewportEvent.ComputeCameraAngles event, LivingEntity entity) {
float times = 1.5f * Math.min(Minecraft.getInstance().getDeltaFrameTime(), 1);
float times = 2f * Math.min(Minecraft.getInstance().getDeltaFrameTime(), 0.8f);
float yaw = event.getYaw();
float pitch = event.getPitch();
float roll = event.getRoll();

View file

@ -123,12 +123,12 @@ public class GunEventHandler {
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_fire_3p"));
if (sound3p != null) {
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.2f, 1f);
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.4f, 1f);
}
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_far"));
if (soundFar != null) {
player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.5f, 1f);
player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.7f, 1f);
}
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_veryfar"));
@ -161,12 +161,12 @@ public class GunEventHandler {
SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_fire_3p_s" : "_fire_3p")));
if (sound3p != null) {
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, soundRadius * 0.2f, 1f);
player.level().playSound(null, player.getOnPos(), sound3p, SoundSource.PLAYERS, soundRadius * 0.4f, 1f);
}
SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_far_s" : "_far")));
if (soundFar != null) {
player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, soundRadius * 0.5f, 1f);
player.level().playSound(null, player.getOnPos(), soundFar, SoundSource.PLAYERS, soundRadius * 0.7f, 1f);
}
SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, name + (barrelType == 2 ? "_veryfar_s" : "_veryfar")));

View file

@ -140,10 +140,14 @@ public class ModSounds {
public static final RegistryObject<SoundEvent> HK_416_FIRE_1P = REGISTRY.register("hk_416_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_fire_1p")));
public static final RegistryObject<SoundEvent> HK_416_FIRE_3P = REGISTRY.register("hk_416_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_fire_3p")));
public static final RegistryObject<SoundEvent> HK_416_FIRE_1P_S = REGISTRY.register("hk_416_fire_1p_s", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_fire_1p_s")));
public static final RegistryObject<SoundEvent> HK_416_FIRE_3P_S = REGISTRY.register("hk_416_fire_3p_s", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_fire_3p_s")));
public static final RegistryObject<SoundEvent> HK_416_FAR = REGISTRY.register("hk_416_far", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_far")));
public static final RegistryObject<SoundEvent> HK_416_VERYFAR = REGISTRY.register("hk_416_veryfar", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_veryfar")));
public static final RegistryObject<SoundEvent> HK_416_RELOAD_NORMAL = REGISTRY.register("hk_416_reload_normal", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_reload_normal")));
public static final RegistryObject<SoundEvent> HK_416_RELOAD_EMPTY = REGISTRY.register("hk_416_reload_empty", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "hk_416_reload_empty")));
public static final RegistryObject<SoundEvent> HK_416_FAR_S = REGISTRY.register("hk_416_far_s", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "ak_12_far_s")));
public static final RegistryObject<SoundEvent> HK_416_VERYFAR_S = REGISTRY.register("hk_416_veryfar_s", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "ak_12_veryfar_s")));
public static final RegistryObject<SoundEvent> RPK_FIRE_1P = REGISTRY.register("rpk_fire_1p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "rpk_fire_1p")));
public static final RegistryObject<SoundEvent> RPK_FIRE_3P = REGISTRY.register("rpk_fire_3p", () -> SoundEvent.createVariableRangeEvent(new ResourceLocation(ModUtils.MODID, "rpk_fire_3p")));

View file

@ -213,7 +213,7 @@ public abstract class GunItem extends Item {
default -> 0;
};
double soundRadius = tag.getInt("Barrel") == 2 ? 0.25 : 1;
double soundRadius = tag.getInt("Barrel") == 2 ? 0.6 : 1;
stack.getOrCreateTag().putDouble("CustomWeight", scopeWeight + barrelWeight + magazineWeight + stockWeight + gripWeight);
stack.getOrCreateTag().putDouble("CustomSoundRadius", soundRadius);

View file

@ -1,6 +1,7 @@
package net.mcreator.superbwarfare.item.gun.rifle;
import net.mcreator.superbwarfare.ModUtils;
import net.mcreator.superbwarfare.client.PoseTool;
import net.mcreator.superbwarfare.client.renderer.item.Hk416ItemRenderer;
import net.mcreator.superbwarfare.event.ClientEventHandler;
import net.mcreator.superbwarfare.init.ModItems;
@ -8,10 +9,10 @@ import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.init.ModTags;
import net.mcreator.superbwarfare.item.AnimatedItem;
import net.mcreator.superbwarfare.item.gun.GunItem;
import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.perk.Perk;
import net.mcreator.superbwarfare.perk.PerkHelper;
import net.mcreator.superbwarfare.tools.GunsTool;
import net.mcreator.superbwarfare.client.PoseTool;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer;
@ -20,11 +21,13 @@ 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.item.Rarity;
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;
@ -74,21 +77,71 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
ItemStack stack = player.getMainHandItem();
if (!stack.is(ModTags.Items.GUN)) return PlayState.STOP;
boolean drum = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.MAGAZINE) == 2;
boolean grip = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 2;
if (stack.getOrCreateTag().getBoolean("is_empty_reloading")) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_drum"));
}
} else {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_empty"));
}
}
}
if (stack.getOrCreateTag().getBoolean("is_normal_reloading")) {
if (drum) {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_drum"));
}
} else {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal"));
}
}
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0 && ClientEventHandler.drawTime < 0.01) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run_fast"));
} else {
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.run_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run"));
}
}
}
if (grip) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.idle_grip"));
} else {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.idle"));
}
}
private PlayState editPredicate(AnimationState<Hk416Item> 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;
boolean grip = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 1 || GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.GRIP) == 2;
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).edit) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.edit"));
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.idle"));
}
@ -97,6 +150,36 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
var idleController = new AnimationController<>(this, "idleController", 3, this::idlePredicate);
data.add(idleController);
var editController = new AnimationController<>(this, "editController", 1, this::editPredicate);
data.add(editController);
}
@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 barrelType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.BARREL);
int magType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.MAGAZINE);
int stockType = GunsTool.getAttachmentType(stack, GunsTool.AttachmentType.STOCK);
int customMag = switch (magType) {
case 1 -> 15;
case 2 -> 30;
default -> 0;
};
double customZoom = switch (scopeType) {
case 0, 1 -> 0;
case 2 -> 2.25;
default -> stack.getOrCreateTag().getDouble("CustomZoom");
};
stack.getOrCreateTag().putBoolean("CanAdjustZoomFov", scopeType == 3);
stack.getOrCreateTag().putDouble("CustomZoom", customZoom);
stack.getOrCreateTag().putInt("customMag", customMag);
}
@Override

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@
"translation": [
4.25,
-13.5,
-22
-26
],
"scale": [
4,

View file

@ -567,6 +567,14 @@
}
]
},
"hk_416_fire_1p_s": {
"sounds": [
{
"name": "superbwarfare:hk_416/hk_416_fire_1p_s",
"stream": false
}
]
},
"hk_416_fire_3p": {
"sounds": [
{
@ -575,6 +583,14 @@
}
]
},
"hk_416_fire_3p_s": {
"sounds": [
{
"name": "superbwarfare:hk_416/hk_416_fire_3p_s",
"stream": false
}
]
},
"hk_416_far": {
"sounds": [
{

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7 KiB

After

Width:  |  Height:  |  Size: 8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -1,4 +1,6 @@
{
"MinZoom": 1.25,
"MaxZoom": 6,
"spread": 3.5,
"recoil_x": 0.0016,
"recoil_y": 0.009,

View file

@ -1,7 +1,7 @@
{
"spread": 1.5,
"recoil_x": 0.005,
"recoil_y": 0.070,
"recoil_y": 0.04,
"damage": 8,
"headshot": 2,
"velocity": 24,