优化代码,添加弹药盒

This commit is contained in:
Atsuihsio 2024-10-02 19:43:58 +08:00
parent e8d6cd1d5f
commit 42f4e11b1b
25 changed files with 436 additions and 154 deletions

View file

@ -234,6 +234,35 @@ public class ClientEventHandler {
}
}
@SubscribeEvent
public static void handleWeaponBreathSway(TickEvent.RenderTickEvent event) {
Player player = Minecraft.getInstance().player;
if (player == null) return;
if (!player.getMainHandItem().is(ModTags.Items.GUN)) return;
float pose;
float times = 2 * Minecraft.getInstance().getDeltaFrameTime();
if (player.isCrouching() && player.getBbHeight() >= 1 && !isProne(player)) {
pose = 0.85f;
} else if (isProne(player)) {
pose = player.getMainHandItem().getOrCreateTag().getDouble("bipod") == 1 ? 0 : 0.25f;
} else {
pose = 1;
}
if (!player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath &&
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom) {
float newPitch = (float) (player.getXRot() - 0.01f * Mth.sin((float) (0.03 * player.tickCount)) * pose * Mth.nextDouble(RandomSource.create(), 0.1, 1) * times);
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = (float) (player.getYRot() - 0.005f * Mth.cos((float) (0.025 * (player.tickCount + 2 * Math.PI))) * pose * Mth.nextDouble(RandomSource.create(), 0.05, 1.25) * times);
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}
}
@SubscribeEvent
public static void computeCameraAngles(ViewportEvent.ComputeCameraAngles event) {
ClientLevel level = Minecraft.getInstance().level;
@ -507,7 +536,7 @@ public class ClientEventHandler {
float times = Minecraft.getInstance().getDeltaFrameTime();
float recoilX = (float) tag.getDouble("recoil_x");
float recoilY = (float) tag.getDouble("recoil_y");
float recoilPitch = 30f;
float recoilPitch = 50f;
float recoilYaw = 25f;
/*

View file

@ -12,9 +12,11 @@ import net.mcreator.superbwarfare.network.message.PlayerGunKillMessage;
import net.mcreator.superbwarfare.perk.PerkHelper;
import net.mcreator.superbwarfare.tools.DamageTypeTool;
import net.mcreator.superbwarfare.tools.SoundTool;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
@ -24,9 +26,11 @@ import net.minecraft.world.damagesource.DamageTypes;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.projectile.Projectile;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.GameRules;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
@ -61,6 +65,42 @@ public class LivingEventHandler {
killIndication(event.getSource());
handleGunPerksWhenDeath(event);
handlePlayerKillEntity(event);
//开启死亡掉落时掉落一个弹药盒
if (!event.getEntity().level().getLevelData().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) && event.getEntity() instanceof Player player) {
var cap =player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
boolean drop = (cap.rifleAmmo + cap.handgunAmmo + cap.shotgunAmmo + cap.sniperAmmo > 0);
if (drop) {
ItemStack stack = new ItemStack(ModItems.AMMOBOX.get());
CompoundTag tag = stack.getOrCreateTag();
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
tag.putInt("rifleAmmo",cap.rifleAmmo);
capability.rifleAmmo = 0;
tag.putInt("handgunAmmo",cap.handgunAmmo);
capability.handgunAmmo = 0;
tag.putInt("shotgunAmmo",cap.shotgunAmmo);
capability.shotgunAmmo = 0;
tag.putInt("sniperAmmo",cap.sniperAmmo);
capability.sniperAmmo = 0;
tag.putBoolean("isDrop",true);
capability.syncPlayerVariables(player);
});
if (player.level() instanceof ServerLevel level) {
var x = player.getX();
var y = player.getY();
var z = player.getZ();
ItemEntity ammobox = new ItemEntity(level, x, (y + 1), z, stack);
ammobox.setPickUpDelay(10);
level.addFreshEntity(ammobox);
}
}
}
}
/**

View file

@ -14,7 +14,6 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.entity.item.ItemEntity;
@ -87,11 +86,8 @@ public class PlayerEventHandler {
if (event.phase == TickEvent.Phase.END) {
if (stack.is(ModTags.Items.GUN)) {
handleWeaponSway(player);
handlePlayerSprint(player);
handleAmmoCount(player);
handleSpecialWeaponAmmo(player);
handleChangeFireRate(player);
handleBocekPulling(player);
isProne(player);
}
@ -111,31 +107,6 @@ public class PlayerEventHandler {
&& !level.getBlockState(BlockPos.containing(player.getX() + 0.7 * player.getLookAngle().x, player.getY() + 1.5, player.getZ() + 0.7 * player.getLookAngle().z)).canOcclude();
}
private static void handleWeaponSway(Player player) {
if (player.getMainHandItem().is(ModTags.Items.GUN)) {
float pose;
if (player.isCrouching() && player.getBbHeight() >= 1 && !isProne(player)) {
pose = 0.85f;
} else if (isProne(player)) {
pose = player.getMainHandItem().getOrCreateTag().getDouble("bipod") == 1 ? 0 : 0.25f;
} else {
pose = 1;
}
if (!player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath &&
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).zoom) {
float newPitch = (float) (player.getXRot() - 0.03f * Mth.sin((float) (0.08 * player.tickCount)) * pose * Mth.nextDouble(RandomSource.create(), 0.1, 1));
player.setXRot(newPitch);
player.xRotO = player.getXRot();
float newYaw = (float) (player.getYRot() - 0.015f * Mth.cos((float) (0.07 * (player.tickCount + 2 * Math.PI))) * pose * Mth.nextDouble(RandomSource.create(), 0.05, 1.25));
player.setYRot(newYaw);
player.yRotO = player.getYRot();
}
}
}
private static void handleBreath(Player player) {
if (player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables()).breath) {
@ -266,27 +237,6 @@ public class PlayerEventHandler {
}
}
public static void handleAmmoCount(Player player) {
ItemStack stack = player.getMainHandItem();
if (stack.is(ModTags.Items.USE_RIFLE_AMMO)) {
stack.getOrCreateTag().putInt("max_ammo",
((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).rifleAmmo));
}
if (stack.is(ModTags.Items.USE_HANDGUN_AMMO) || stack.is(ModTags.Items.SMG)) {
stack.getOrCreateTag().putInt("max_ammo",
((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).handgunAmmo));
}
if (stack.is(ModTags.Items.USE_SHOTGUN_AMMO)) {
stack.getOrCreateTag().putInt("max_ammo",
((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).shotgunAmmo));
}
if (stack.is(ModTags.Items.USE_SNIPER_AMMO)) {
stack.getOrCreateTag().putInt("max_ammo",
((player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables())).sniperAmmo));
}
}
private static void handleGround(Player player) {
if (player.onGround()) {
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
@ -307,15 +257,6 @@ public class PlayerEventHandler {
}
}
private static void handleChangeFireRate(Player player) {
ItemStack stack = player.getMainHandItem();
if (stack.is(ModTags.Items.GUN)) {
if (stack.getOrCreateTag().getDouble("cg") > 0) {
stack.getOrCreateTag().putDouble("cg", (stack.getOrCreateTag().getDouble("cg") - 1));
}
}
}
private static void handleBocekPulling(Player player) {
ItemStack mainHandItem = player.getMainHandItem();
CompoundTag tag = mainHandItem.getOrCreateTag();

View file

@ -92,6 +92,7 @@ public class ModItems {
public static final RegistryObject<Item> SNIPER_AMMO_BOX = AMMO.register("sniper_ammo_box", SniperAmmoBox::new);
public static final RegistryObject<Item> SHOTGUN_AMMO_BOX = AMMO.register("shotgun_ammo_box", ShotgunAmmoBox::new);
public static final RegistryObject<Item> CREATIVE_AMMO_BOX = AMMO.register("creative_ammo_box", () -> new Item(new Item.Properties().rarity(Rarity.EPIC)));
public static final RegistryObject<Item> AMMOBOX = AMMO.register("ammobox", AmmoBox::new);
public static final RegistryObject<Item> TASER_ELECTRODE = AMMO.register("taser_electrode", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> GRENADE_40MM = AMMO.register("grenade_40mm", () -> new Item(new Item.Properties()));
public static final RegistryObject<Item> JAVELIN_MISSILE = AMMO.register("javelin_missile", () -> new Item(new Item.Properties()));
@ -253,7 +254,7 @@ public class ModItems {
/**
* 单独注册用于Tab图标不要删
*/
public static final RegistryObject<Item> SHORTCUT_PACK = PERKS.register("shortcut_pack", () -> new Item(new Item.Properties().rarity(Rarity.EPIC)));
public static final RegistryObject<Item> SHORTCUT_PACK = PERKS.register("shortcut_pack", shortcutPack::new);
public static final RegistryObject<Item> EMPTY_PERK = PERKS.register("empty_perk", () -> new Item(new Item.Properties()));

View file

@ -0,0 +1,142 @@
package net.mcreator.superbwarfare.item.common.ammo;
import net.mcreator.superbwarfare.init.ModSounds;
import net.mcreator.superbwarfare.network.ModVariables;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class AmmoBox extends Item {
public AmmoBox() {
super(new Properties().stacksTo(1).rarity(Rarity.COMMON));
}
@Override
public InteractionResultHolder<ItemStack> use(Level level, Player player, InteractionHand hand) {
ItemStack stack = player.getItemInHand(hand);
CompoundTag tag = stack.getOrCreateTag();
player.getCooldowns().addCooldown(this, 10);
var cap =player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new ModVariables.PlayerVariables());
player.getCapability(ModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
if (!player.isCrouching()) {
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) {
capability.rifleAmmo = cap.rifleAmmo + tag.getInt("rifleAmmo");
tag.putInt("rifleAmmo",0);
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) {
capability.handgunAmmo = cap.handgunAmmo + tag.getInt("handgunAmmo");
tag.putInt("handgunAmmo",0);
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) {
capability.shotgunAmmo = cap.shotgunAmmo + tag.getInt("shotgunAmmo");
tag.putInt("shotgunAmmo",0);
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) {
capability.sniperAmmo = cap.sniperAmmo + tag.getInt("sniperAmmo");
tag.putInt("sniperAmmo",0);
}
capability.syncPlayerVariables(player);
if (!level.isClientSide()) {
level.playSound(null, player.blockPosition(), ModSounds.BULLET_SUPPLY.get(), SoundSource.PLAYERS, 1, 1);
}
if (tag.getBoolean("isDrop")) {
stack.shrink(1);
}
} else {
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) {
tag.putInt("rifleAmmo",tag.getInt("rifleAmmo") + cap.rifleAmmo);
capability.rifleAmmo = 0;
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) {
tag.putInt("handgunAmmo",tag.getInt("handgunAmmo") + cap.handgunAmmo);
capability.handgunAmmo = 0;
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) {
tag.putInt("shotgunAmmo",tag.getInt("shotgunAmmo") + cap.shotgunAmmo);
capability.shotgunAmmo = 0;
}
if (stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) {
tag.putInt("sniperAmmo",tag.getInt("sniperAmmo") + cap.sniperAmmo);
capability.sniperAmmo = 0;
}
capability.syncPlayerVariables(player);
if (!level.isClientSide()) {
level.playSound(null, player.blockPosition(), SoundEvents.ARROW_HIT_PLAYER, SoundSource.PLAYERS, 1, 1);
}
}
});
return InteractionResultHolder.consume(stack);
}
@Override
public boolean onEntitySwing(ItemStack itemstack, LivingEntity entity) {
boolean retval = super.onEntitySwing(itemstack, entity);
if (entity instanceof Player player && player.isCrouching()) {
itemstack.getOrCreateTag().putInt("type",itemstack.getOrCreateTag().getInt("type") + 1);
if (itemstack.getOrCreateTag().getInt("type") > 4) {
itemstack.getOrCreateTag().putInt("type",0);
}
if (itemstack.getOrCreateTag().getInt("type") == 0) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.all").withStyle(ChatFormatting.WHITE),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 1) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.rifle").withStyle(ChatFormatting.GREEN),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 2) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.handgun").withStyle(ChatFormatting.AQUA),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 3) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.shotgun").withStyle(ChatFormatting.RED),true);
}
if (itemstack.getOrCreateTag().getInt("type") == 4) {
player.displayClientMessage(Component.translatable("des.superbwarfare.tips.ammo_type.sniper").withStyle(ChatFormatting.GOLD),true);
}
entity.playSound(ModSounds.FIRE_RATE.get(), 1f, 1f);
}
return retval;
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list, TooltipFlag flag) {
TooltipTool.ammoBoxTips(list, stack);
}
}

View file

@ -93,14 +93,6 @@ public class Glock18Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.change_fire_rate"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.glock.change_fire_rate2"));
}
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.glock.idle"));
}
return PlayState.STOP;

View file

@ -102,14 +102,6 @@ public class M60Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.reload2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m60.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m60.run_fast"));

View file

@ -98,14 +98,6 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak47.run_fast"));

View file

@ -104,14 +104,6 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.ak47.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.ak47.run_fast"));

View file

@ -99,14 +99,6 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run_fast"));

View file

@ -99,14 +99,6 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m4.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m4.run_fast"));

View file

@ -99,14 +99,6 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.m14changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.m14.run_fast"));

View file

@ -98,14 +98,6 @@ public class Qbz95Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.qbz95.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.qbz95.run_fast"));

View file

@ -105,14 +105,6 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.aa12.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.aa12.run_fast"));

View file

@ -98,18 +98,6 @@ public class VectorItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.reload_normal"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 0 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.changefirerate3"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 1 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.changefirerate2"));
}
if (stack.getOrCreateTag().getInt("fire_mode") == 2 && stack.getOrCreateTag().getDouble("cg") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.vec.changefirerate"));
}
if (player.isSprinting() && player.onGround() && player.getPersistentData().getDouble("noRun") == 0) {
if (player.hasEffect(MobEffects.MOVEMENT_SPEED)) {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.vec.run_fast"));

View file

@ -0,0 +1,24 @@
package net.mcreator.superbwarfare.item;
import net.mcreator.superbwarfare.tools.TooltipTool;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Rarity;
import net.minecraft.world.item.TooltipFlag;
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public class shortcutPack extends Item {
public shortcutPack() {
super(new Properties().rarity(Rarity.EPIC));
}
@Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> list, TooltipFlag flag) {
TooltipTool.shortcutPackTips(list);
}
}

View file

@ -302,7 +302,6 @@ public class FireMessage {
player.getInventory().clearOrCountMatchingItems(p -> Items.ARROW == p.getItem(), 1, player.inventoryMenu.getCraftSlots());
}
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}
@ -467,7 +466,6 @@ public class FireMessage {
stack.getOrCreateTag().putInt("fire_animation", 2);
stack.getOrCreateTag().putInt("ammo", (stack.getOrCreateTag().getInt("ammo") - 1));
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}
@ -527,7 +525,6 @@ public class FireMessage {
tag.putInt("fire_animation", 2);
tag.putInt("ammo", tag.getInt("ammo") - 1);
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}
@ -588,7 +585,6 @@ public class FireMessage {
tag.putInt("fire_animation", 2);
tag.putInt("ammo", tag.getInt("ammo") - 1);
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}

View file

@ -51,7 +51,6 @@ public class FireModeMessage {
serverPlayer.connection.send(new ClientboundSoundPacket(new Holder.Direct<>(ModSounds.FIRE_RATE.get()),
SoundSource.PLAYERS, serverPlayer.getX(), serverPlayer.getY(), serverPlayer.getZ(), 1f, 1f, serverPlayer.level().random.nextLong()));
}
tag.putDouble("cg", 10);
}
public static void changeFireMode(Player player) {

View file

@ -160,8 +160,6 @@ public class ShootMessage {
playGunSounds(player);
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}
@ -214,7 +212,6 @@ public class ShootMessage {
tag.putInt("fire_animation", 2);
stack.getOrCreateTag().putBoolean("shoot", true);
if (player.level() instanceof ServerLevel && player instanceof ServerPlayer serverPlayer) {
ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShootClientMessage(10));
}

View file

@ -260,4 +260,29 @@ public class TooltipTool {
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal("Distance:" + new DecimalFormat("##.#").format(player.distanceTo(entity)) + "M").withStyle(ChatFormatting.GRAY)));
}
public static void ammoBoxTips(List<Component> tooltip, ItemStack stack) {
tooltip.add(Component.translatable("des.superbwarfare.use_tip.ammobox").withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("des.superbwarfare.tips.rifleammo").withStyle(ChatFormatting.GREEN)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "rifleAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 1) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.handgunammo").withStyle(ChatFormatting.AQUA)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "handgunAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 2) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.shotgunammo").withStyle(ChatFormatting.RED)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "shotgunAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 3) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
tooltip.add(Component.translatable("des.superbwarfare.tips.sniperammo").withStyle(ChatFormatting.GOLD)
.append(Component.literal("").withStyle(ChatFormatting.RESET))
.append(Component.literal(new DecimalFormat("##").format(ItemNBTTool.getInt(stack, "sniperAmmo", 0)) + ((stack.getOrCreateTag().getInt("type") == 0 || stack.getOrCreateTag().getInt("type") == 4) ? " ←-" : " ")).withStyle(ChatFormatting.BOLD)));
}
public static void shortcutPackTips(List<Component> tooltip) {
tooltip.add(Component.translatable("des.superbwarfare.tips.shortcutpack").withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("des.superbwarfare.use_tip.shortcutpack"));
}
}

View file

@ -53,6 +53,21 @@
"des.superbwarfare.tips.upgradepoint": "Upgrade Point: ",
"des.superbwarfare.tips.rpm": "Rpm: ",
"item.superbwarfare.ammobox": "AmmoBox",
"des.superbwarfare.tips.rifleammo": "Storage Rifle Ammo: ",
"des.superbwarfare.tips.handgunammo": "Storage Handgun Ammo: ",
"des.superbwarfare.tips.shotgunammo": "Storage Shotgun Ammo: ",
"des.superbwarfare.tips.sniperammo": "Storage Sniper Ammo: ",
"des.superbwarfare.tips.ammo_type.all": "All Ammo Choosed",
"des.superbwarfare.tips.ammo_type.rifle": "Rifle Ammo Choosed",
"des.superbwarfare.tips.ammo_type.handgun": "Handgun Ammo Choosed",
"des.superbwarfare.tips.ammo_type.shotgun": "Shotgun Ammo Choosed",
"des.superbwarfare.tips.ammo_type.sniper": "Sniper Ammo Choosed",
"des.superbwarfare.tips.shortcutpack": "Really?",
"des.superbwarfare.use_tip.shortcutpack": "将枪械和捷径包在铁砧合成,可直接获得一个升级点数",
"item.superbwarfare.vector_blueprint": "VECTOR Blueprint",
"item.superbwarfare.m_60_blueprint": "M60 Blueprint",
"item.superbwarfare.hk_416_blueprint": "Hk-416 Blueprint",
@ -370,5 +385,7 @@
"config.superbwarfare.client.display.camera_rotate": "视角摇晃",
"config.superbwarfare.client.display.camera_rotate.des": "手持枪械时,视角会出现轻微的摇晃",
"config.superbwarfare.client.display.armor_plate_hud": "Armor Plate HUD",
"config.superbwarfare.client.display.armor_plate_hud.des": "开启时,在屏幕左下角显示当前胸甲装备的防弹插板的耐久"
"config.superbwarfare.client.display.armor_plate_hud.des": "开启时,在屏幕左下角显示当前胸甲装备的防弹插板的耐久",
"des.superbwarfare.use_tip.ammobox": "潜行左键切换弹药种类,潜行右键取出身上该类型弹药,非潜行右键取出相应种类弹药。"
}

View file

@ -53,6 +53,21 @@
"des.superbwarfare.tips.distance": "无人机距离你: ",
"des.superbwarfare.tips.rpm": "射速: ",
"item.superbwarfare.ammobox": "弹药盒",
"des.superbwarfare.tips.rifleammo": "已存储的步枪弹药: ",
"des.superbwarfare.tips.handgunammo": "已存储的手枪弹药: ",
"des.superbwarfare.tips.shotgunammo": "已存储的霰弹弹药: ",
"des.superbwarfare.tips.sniperammo": "已存储的狙击弹药: ",
"des.superbwarfare.tips.ammo_type.all": "已选择所有弹药种类",
"des.superbwarfare.tips.ammo_type.rifle": "已选择步枪弹药",
"des.superbwarfare.tips.ammo_type.handgun": "已选择手枪弹药",
"des.superbwarfare.tips.ammo_type.shotgun": "已选择霰弹弹药",
"des.superbwarfare.tips.ammo_type.sniper": "已选择狙击弹药",
"des.superbwarfare.tips.shortcutpack": "真的吗?",
"des.superbwarfare.use_tip.shortcutpack": "将枪械和捷径包在铁砧合成,可直接获得一个升级点数",
"item.superbwarfare.vector_blueprint": "短剑冲锋枪蓝图",
"item.superbwarfare.m_60_blueprint": "M60通用机枪蓝图",
"item.superbwarfare.hk_416_blueprint": "Hk-416突击步枪蓝图",

View file

@ -0,0 +1,120 @@
{
"credit": "Made with Blockbench",
"texture_size": [32, 32],
"textures": {
"0": "superbwarfare:item/ammobox",
"particle": "superbwarfare:item/ammobox"
},
"elements": [
{
"from": [7.5, 5.58982, 4.93105],
"to": [8.5, 5.83982, 6.43105],
"rotation": {"angle": -22.5, "axis": "x", "origin": [8, 5.71482, 4.68105]},
"faces": {
"north": {"uv": [8.5, 3, 9, 3.125], "texture": "#0"},
"east": {"uv": [8.5, 1, 9.25, 1.125], "texture": "#0"},
"south": {"uv": [8.5, 3.5, 9, 3.625], "texture": "#0"},
"west": {"uv": [8.5, 1.5, 9.25, 1.625], "texture": "#0"},
"up": {"uv": [8, 7.75, 7.5, 7], "texture": "#0"},
"down": {"uv": [8.5, 7, 8, 7.75], "texture": "#0"}
}
},
{
"from": [6, 0, 4],
"to": [10, 5, 12],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 1, 8.5]},
"faces": {
"north": {"uv": [6.5, 0, 8.5, 2.5], "texture": "#0"},
"east": {"uv": [0, 0, 4, 2.5], "texture": "#0"},
"south": {"uv": [6.5, 2.5, 8.5, 5], "texture": "#0"},
"west": {"uv": [0, 2.5, 4, 5], "texture": "#0"},
"up": {"uv": [2, 9, 0, 5], "texture": "#0"},
"down": {"uv": [4, 5, 2, 9], "texture": "#0"}
}
},
{
"from": [5.75, 5, 3.75],
"to": [10.25, 6, 12.25],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 1, 8.5]},
"faces": {
"north": {"uv": [6.5, 6, 8.75, 6.5], "texture": "#0"},
"east": {"uv": [6.5, 5, 10.75, 5.5], "texture": "#0"},
"south": {"uv": [6.5, 6.5, 8.75, 7], "texture": "#0"},
"west": {"uv": [6.5, 5.5, 10.75, 6], "texture": "#0"},
"up": {"uv": [6.25, 4.25, 4, 0], "texture": "#0"},
"down": {"uv": [6.25, 4.5, 4, 8.75], "texture": "#0"}
}
},
{
"from": [7.5, 6.25, 6.25],
"to": [8.5, 6.5, 9.75],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 1, 8.5]},
"faces": {
"north": {"uv": [8.5, 4, 9, 4.125], "texture": "#0"},
"east": {"uv": [8.5, 0, 10.25, 0.125], "texture": "#0"},
"south": {"uv": [8.5, 4.5, 9, 4.625], "texture": "#0"},
"west": {"uv": [8.5, 0.5, 10.25, 0.625], "texture": "#0"},
"up": {"uv": [7, 8.75, 6.5, 7], "texture": "#0"},
"down": {"uv": [7.5, 7, 7, 8.75], "texture": "#0"}
}
},
{
"from": [7.5, 5.58982, 9.56895],
"to": [8.5, 5.83982, 11.06895],
"rotation": {"angle": 22.5, "axis": "x", "origin": [8, 5.71482, 11.31895]},
"faces": {
"north": {"uv": [8.5, 7, 9, 7.125], "texture": "#0"},
"east": {"uv": [8.5, 2, 9.25, 2.125], "texture": "#0"},
"south": {"uv": [8.5, 7.5, 9, 7.625], "texture": "#0"},
"west": {"uv": [8.5, 2.5, 9.25, 2.625], "texture": "#0"},
"up": {"uv": [8, 8.75, 7.5, 8], "texture": "#0"},
"down": {"uv": [8.5, 8, 8, 8.75], "texture": "#0"}
}
}
],
"gui_light": "front",
"display": {
"thirdperson_righthand": {
"rotation": [90, 0, 0],
"translation": [0, -2, 2]
},
"thirdperson_lefthand": {
"rotation": [90, 0, 0],
"translation": [0, -2, 2]
},
"firstperson_righthand": {
"rotation": [7.9, 31.95, -3.04],
"translation": [-1.75, 8.75, 0]
},
"firstperson_lefthand": {
"rotation": [7.9, 31.95, -3.04],
"translation": [-1.75, 8.75, 0]
},
"ground": {
"translation": [0, 5.5, 0]
},
"gui": {
"rotation": [45, 45, 0],
"translation": [0, 5, -3.25],
"scale": [1.5, 1.5, 1.5]
},
"head": {
"rotation": [0, 90, 0],
"translation": [0, 16.75, -1.5],
"scale": [1.3, 1.3, 1.3]
},
"fixed": {
"rotation": [0, 90, 0],
"translation": [0, 8.5, -3.25],
"scale": [2, 2, 2]
}
},
"groups": [
{
"name": "ammobox",
"origin": [8, 5.71482, 11.31895],
"color": 0,
"children": [0, 1, 2, 3, 4]
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"pattern": [
"aba",
"aaa"
],
"key": {
"a": {
"item": "minecraft:iron_ingot"
},
"b": {
"tag": "forge:dyes/green"
}
},
"result": {
"item": "superbwarfare:ammobox",
"count": 1
}
}