重写所有playsound

This commit is contained in:
Light_Quanta 2024-05-19 22:24:47 +08:00
parent ea1738a959
commit cdd6d457ee
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
32 changed files with 168 additions and 313 deletions

View file

@ -215,10 +215,6 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated
if (!this.level().isClientSide()) this.discard(); if (!this.level().isClientSide()) this.discard();
} }
if (data.getDouble("def") >= 100) { if (data.getDouble("def") >= 100) {
if (!this.level().isClientSide() && this.getServer() != null) {
this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4,
this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "playsound minecraft:item.shield.break player @p ~ ~ ~ 1 1");
}
if (!this.level().isClientSide()) this.discard(); if (!this.level().isClientSide()) this.discard();
if (!level.isClientSide()) { if (!level.isClientSide()) {

View file

@ -74,7 +74,6 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
@Override @Override
protected void onHitEntity(EntityHitResult result) { protected void onHitEntity(EntityHitResult result) {
final Vec3 position = this.position();
Entity entity = result.getEntity(); Entity entity = result.getEntity();
if (this.getOwner() instanceof LivingEntity living) { if (this.getOwner() instanceof LivingEntity living) {
living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { living.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> {
@ -82,8 +81,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4, living.level().playSound(null, living.blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:indication voice @a ~ ~ ~ 1 1");
} }
} }
@ -115,7 +113,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
if (box != null) { if (box != null) {
box = box.move(boundingBox.getCenter().x, boundingBox.minY, boundingBox.getCenter().z); box = box.move(boundingBox.getCenter().x, boundingBox.minY, boundingBox.getCenter().z);
Optional<Vec3> headshotHitPos = box.clip(startVec, endVec); Optional<Vec3> headshotHitPos = box.clip(startVec, endVec);
if (!headshotHitPos.isPresent()) { if (headshotHitPos.isEmpty()) {
box = box.inflate(0.2, 0.2, 0.2); box = box.inflate(0.2, 0.2, 0.2);
headshotHitPos = box.clip(startVec, endVec); headshotHitPos = box.clip(startVec, endVec);
} }
@ -145,7 +143,7 @@ public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier {
public void onHitBlock(BlockHitResult blockHitResult) { public void onHitBlock(BlockHitResult blockHitResult) {
super.onHitBlock(blockHitResult); super.onHitBlock(blockHitResult);
if (this.getPersistentData().getInt("fuse") > 0) { if (this.getPersistentData().getInt("fuse") > 0) {
if (this.level() instanceof ServerLevel level) { if (this.level() instanceof ServerLevel) {
this.level().explode(this, this.getX(), this.getY(), this.getZ(), 5.5f, Level.ExplosionInteraction.NONE); this.level().explode(this, this.getX(), this.getY(), this.getZ(), 5.5f, Level.ExplosionInteraction.NONE);
} }
} }

View file

@ -3,12 +3,14 @@ package net.mcreator.target.entity;
import net.mcreator.target.headshot.BoundingBoxManager; import net.mcreator.target.headshot.BoundingBoxManager;
import net.mcreator.target.headshot.IHeadshotBox; import net.mcreator.target.headshot.IHeadshotBox;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.protocol.game.ClientGamePacketListener;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.EntityType;
@ -91,8 +93,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4, living.level().playSound(null, living.blockPosition(), TargetModSounds.INDICATION.get(), SoundSource.VOICE, 1, 1);
living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:indication voice @a ~ ~ ~ 1 1");
} }
} }
if (this.getPersistentData().getInt("time") > 0) { if (this.getPersistentData().getInt("time") > 0) {
@ -124,7 +125,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
if (box != null) { if (box != null) {
box = box.move(boundingBox.getCenter().x, boundingBox.minY, boundingBox.getCenter().z); box = box.move(boundingBox.getCenter().x, boundingBox.minY, boundingBox.getCenter().z);
Optional<Vec3> headshotHitPos = box.clip(startVec, endVec); Optional<Vec3> headshotHitPos = box.clip(startVec, endVec);
if (!headshotHitPos.isPresent()) { if (headshotHitPos.isEmpty()) {
box = box.inflate(0.2, 0.2, 0.2); box = box.inflate(0.2, 0.2, 0.2);
headshotHitPos = box.clip(startVec, endVec); headshotHitPos = box.clip(startVec, endVec);
} }
@ -139,8 +140,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
capability.syncPlayerVariables(living); capability.syncPlayerVariables(living);
}); });
if (!living.level().isClientSide() && living.getServer() != null) { if (!living.level().isClientSide() && living.getServer() != null) {
living.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, living.position(), living.getRotationVector(), living.level() instanceof ServerLevel ? (ServerLevel) living.level() : null, 4, living.playSound(TargetModSounds.HEADSHOT.get(), 1, 1);
living.getName().getString(), living.getDisplayName(), living.level().getServer(), living), "playsound target:headshot voice @a ~ ~ ~ 1 1");
} }
} }
} }
@ -166,6 +166,7 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier {
} }
} }
} }
@Override @Override
public void tick() { public void tick() {
super.tick(); super.tick();

View file

@ -123,6 +123,7 @@ public class Rocket extends Item implements GeoItem, AnimatedItem {
level.explode(null, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE); level.explode(null, sourceentity.getX(), sourceentity.getY() + 1, sourceentity.getZ(), 6, Level.ExplosionInteraction.NONE);
if (!sourceentity.level().isClientSide() && sourceentity.getServer() != null) { if (!sourceentity.level().isClientSide() && sourceentity.getServer() != null) {
// TODO what the hell is this?
sourceentity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, sourceentity.position(), sourceentity.getRotationVector(), sourceentity.level() instanceof ServerLevel ? (ServerLevel) sourceentity.level() : null, 4, sourceentity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, sourceentity.position(), sourceentity.getRotationVector(), sourceentity.level() instanceof ServerLevel ? (ServerLevel) sourceentity.level() : null, 4,
sourceentity.getName().getString(), sourceentity.getDisplayName(), sourceentity.getServer(), sourceentity), "playsound target:target:mediumexp"); sourceentity.getName().getString(), sourceentity.getDisplayName(), sourceentity.getServer(), sourceentity), "playsound target:target:mediumexp");
} }

View file

@ -7,19 +7,13 @@ import net.mcreator.target.client.renderer.item.AK47ItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -191,9 +185,8 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 57) { if (tag.getDouble("reload_time") == 57) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide()) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.AK_47_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:ak_47_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -212,9 +205,8 @@ public class AK47Item extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 41) { if (tag.getDouble("reload_time") == 41) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide()) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.AK_47_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:ak_47_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -12,11 +12,9 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -187,9 +185,8 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 55) { if (tag.getDouble("reload_time") == 55) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.AA_12_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:aa_12_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -208,11 +205,8 @@ public class Aa12Item extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 44) { if (tag.getDouble("reload_time") == 44) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
{ if (entity instanceof ServerPlayer serverPlayer) {
if (!entity.level().isClientSide() && entity.getServer() != null) { SoundTool.playLocalSound(serverPlayer, TargetModSounds.AA_12_RELOAD_NORMAL.get(), 100, 1);
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4,
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:aa_12_reload_normal player @s ~ ~ ~ 100 1");
}
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,13 @@ import net.mcreator.target.client.renderer.item.AbekiriItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -182,9 +176,8 @@ public class Abekiri extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 99) { if (tag.getDouble("reload_time") == 99) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide()) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.ABEKIRI_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:abekiri_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -203,9 +196,8 @@ public class Abekiri extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") == 1) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") == 1) {
if (tag.getDouble("reload_time") == 83) { if (tag.getDouble("reload_time") == 83) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (!entity.level().isClientSide()) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.ABEKIRI_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:abekiri_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.DevotionItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -178,9 +173,8 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") == 0) { if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") == 0) {
if (itemTag.getDouble("reload_time") == 71) { if (itemTag.getDouble("reload_time") == 71) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer player) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.DEVOTION_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:devotion_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (mainHandItem.getItem() == itemstack.getItem() if (mainHandItem.getItem() == itemstack.getItem()
@ -199,9 +193,8 @@ public class Devotion extends GunItem implements GeoItem, AnimatedItem {
} else if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") > 0) { } else if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") > 0) {
if (itemTag.getDouble("reload_time") == 51) { if (itemTag.getDouble("reload_time") == 51) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer player) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.DEVOTION_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:devotion_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (mainHandItem.getItem() == itemstack.getItem() if (mainHandItem.getItem() == itemstack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.Hk416ItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -187,11 +182,8 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 55) { if (tag.getDouble("reload_time") == 55) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
{ if (entity instanceof ServerPlayer serverPlayer) {
if (!entity.level().isClientSide() && entity.getServer() != null) { SoundTool.playLocalSound(serverPlayer, TargetModSounds.HK_416_RELOAD_EMPTY.get(), 100, 1);
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4,
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:hk_416_reload_empty player @s ~ ~ ~ 100 1");
}
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -211,9 +203,8 @@ public class Hk416Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getDouble("reload_time") == 41) { if (tag.getDouble("reload_time") == 41) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
{ {
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.HK_416_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:hk_416_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
} }

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.HuntingRifleItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -179,9 +174,8 @@ public class HuntingRifle extends GunItem implements GeoItem, AnimatedItem {
if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") == 0) { if (itemTag.getBoolean("reloading") && itemTag.getInt("ammo") == 0) {
if (itemTag.getDouble("reload_time") == 61) { if (itemTag.getDouble("reload_time") == 61) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.HUNTING_RIFLE_RELOAD.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:hunting_rifle_reload player @s ~ ~ ~ 100 1");
} }
} }
if (mainHandItem.getItem() == itemstack.getItem() if (mainHandItem.getItem() == itemstack.getItem()

View file

@ -12,11 +12,9 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -179,9 +177,8 @@ public class Kraber extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 83) { if (tag.getDouble("reload_time") == 83) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.KRABER_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:kraber_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -200,11 +197,8 @@ public class Kraber extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 65) { if (tag.getDouble("reload_time") == 65) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
{ if (entity instanceof ServerPlayer serverPlayer) {
if (!entity.level().isClientSide() && entity.getServer() != null) { SoundTool.playLocalSound(serverPlayer, TargetModSounds.KRABER_RELOAD_NORMAL.get(), 100, 1);
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4,
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:kraber_reload_normal player @s ~ ~ ~ 100 1");
}
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.M4ItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -185,9 +180,8 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
} }
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 55) { if (tag.getDouble("reload_time") == 55) {
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_4_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_4_reload_empty player @s ~ ~ ~ 100 1");
} }
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
} }
@ -206,9 +200,8 @@ public class M4Item extends GunItem implements GeoItem, AnimatedItem {
} }
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 41) { if (tag.getDouble("reload_time") == 41) {
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_4_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_4_reload_normal player @s ~ ~ ~ 100 1");
} }
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
} }

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.M60ItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -168,9 +163,8 @@ public class M60Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 129) { if (tag.getDouble("reload_time") == 129) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_60_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_60_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (tag.getDouble("reload_time") <= 55) { if (tag.getDouble("reload_time") <= 55) {
@ -192,9 +186,8 @@ public class M60Item extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 111) { if (tag.getDouble("reload_time") == 111) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_60_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_60_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -8,16 +8,15 @@ import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.mcreator.target.tools.TooltipTool; import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -187,9 +186,8 @@ public class M79Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading")) { if (tag.getBoolean("reloading")) {
if (tag.getDouble("reload_time") == 86) { if (tag.getDouble("reload_time") == 86) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_79_RELOAD.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_79_reload player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -9,16 +9,15 @@ import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.mcreator.target.tools.TooltipTool; import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -200,9 +199,8 @@ public class M870Item extends GunItem implements GeoItem, AnimatedItem {
tag.putDouble("loading", 16); tag.putDouble("loading", 16);
player.getCooldowns().addCooldown(itemstack.getItem(), 16); player.getCooldowns().addCooldown(itemstack.getItem(), 16);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_870_RELOAD_LOOP.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_870_reloadloop player @s ~ ~ ~ 100 1");
} }
tag.putBoolean("load_index", tag.getBoolean("load_index")); tag.putBoolean("load_index", tag.getBoolean("load_index"));
} }

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.M98bItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -182,9 +177,8 @@ public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 79) { if (tag.getDouble("reload_time") == 79) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_98B_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_98b_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -203,9 +197,8 @@ public class M98bItem extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 57) { if (tag.getDouble("reload_time") == 57) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_98B_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_98b_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -9,16 +9,15 @@ import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.mcreator.target.tools.TooltipTool; import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -170,7 +169,6 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
if (entity instanceof Player player) { if (entity instanceof Player player) {
var tag = itemstack.getOrCreateTag(); var tag = itemstack.getOrCreateTag();
double id = tag.getDouble("id"); double id = tag.getDouble("id");
tag.getInt("ammo");
if (player.getMainHandItem().getOrCreateTag().getDouble("id") != tag.getDouble("id")) { if (player.getMainHandItem().getOrCreateTag().getDouble("id") != tag.getDouble("id")) {
tag.putDouble("finish", 0); tag.putDouble("finish", 0);
tag.putBoolean("reloading", false); tag.putBoolean("reloading", false);
@ -199,9 +197,8 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
} else { } else {
tag.putDouble("loading", 16); tag.putDouble("loading", 16);
player.getCooldowns().addCooldown(itemstack.getItem(), 16); player.getCooldowns().addCooldown(itemstack.getItem(), 16);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.MARLIN_LOOP.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:marlin_loop player @s ~ ~ ~ 100 1");
} }
tag.putBoolean("load_index", tag.getBoolean("load_index")); tag.putBoolean("load_index", tag.getBoolean("load_index"));
} }
@ -220,9 +217,8 @@ public class MarlinItem extends GunItem implements GeoItem, AnimatedItem {
tag.putDouble("finish", 19); tag.putDouble("finish", 19);
player.getCooldowns().addCooldown(itemstack.getItem(), 19); player.getCooldowns().addCooldown(itemstack.getItem(), 19);
tag.putBoolean("reloading", false); tag.putBoolean("reloading", false);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.MARLIN_END.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:marlin_end player @s ~ ~ ~ 100 1");
} }
} }
} }

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.Mk14ItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -163,9 +158,8 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 55) { if (tag.getDouble("reload_time") == 55) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.MK_14_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:mk_14_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -187,9 +181,8 @@ public class Mk14Item extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 45) { if (tag.getDouble("reload_time") == 45) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.MK_14_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:mk_14_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -8,16 +8,14 @@ import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.mcreator.target.tools.TooltipTool; import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -191,8 +189,7 @@ public class RpgItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getDouble("reload_time") == 91) { if (tag.getDouble("reload_time") == 91) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (entity.getServer() != null) { if (entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.RPG_RELOAD.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:rpg_reload player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.RpkItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -186,9 +181,8 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 83) { if (tag.getDouble("reload_time") == 83) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.RPK_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:rpk_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemstack.getItem() if (player.getMainHandItem().getItem() == itemstack.getItem()
@ -207,9 +201,8 @@ public class RpkItem extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 66) { if (tag.getDouble("reload_time") == 66) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.RPK_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:rpk_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemstack.getItem() if (player.getMainHandItem().getItem() == itemstack.getItem()

View file

@ -12,11 +12,9 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -103,11 +101,11 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.draw")); return event.setAndContinue(RawAnimation.begin().thenLoop("animation.sentinel.draw"));
} }
if (stack.getOrCreateTag().getBoolean("zoom_fire") == true && stack.getOrCreateTag().getDouble("bolt_action_anim") > 0) { if (stack.getOrCreateTag().getBoolean("zoom_fire") && stack.getOrCreateTag().getDouble("bolt_action_anim") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift2")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift2"));
} }
if (stack.getOrCreateTag().getBoolean("zoom_fire") == false && stack.getOrCreateTag().getDouble("bolt_action_anim") > 0) { if (!stack.getOrCreateTag().getBoolean("zoom_fire") && stack.getOrCreateTag().getDouble("bolt_action_anim") > 0) {
return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift")); return event.setAndContinue(RawAnimation.begin().thenPlay("animation.sentinel.shift"));
} }
@ -188,9 +186,8 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 73) { if (tag.getDouble("reload_time") == 73) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SENTINEL_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:sentinel_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -209,9 +206,8 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 53) { if (tag.getDouble("reload_time") == 53) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SENTINEL_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:sentinel_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -243,9 +239,8 @@ public class SentinelItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getDouble("charging") == 1) { if (tag.getDouble("charging") == 1) {
if (tag.getDouble("charging_time") == 127) { if (tag.getDouble("charging_time") == 127) {
entity.getPersistentData().putDouble("cid", cid); entity.getPersistentData().putDouble("cid", cid);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SENTINEL_CHARGE.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:sentinel_charge player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.SksItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -182,9 +177,8 @@ public class SksItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 57) { if (tag.getDouble("reload_time") == 57) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SKS_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:sks_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -206,9 +200,8 @@ public class SksItem extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 41) { if (tag.getDouble("reload_time") == 41) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SKS_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:sks_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -7,19 +7,14 @@ import net.mcreator.target.client.renderer.item.SvdItemRenderer;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunInfo; import net.mcreator.target.tools.*;
import net.mcreator.target.tools.GunReload;
import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -156,9 +151,8 @@ public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) { if (tag.getBoolean("reloading") && tag.getInt("ammo") == 0) {
if (tag.getDouble("reload_time") == 66) { if (tag.getDouble("reload_time") == 66) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SVD_RELOAD_EMPTY.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:svd_reload_empty player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()
@ -180,9 +174,8 @@ public class SvdItem extends GunItem implements GeoItem, AnimatedItem {
} else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) { } else if (tag.getBoolean("reloading") && tag.getInt("ammo") > 0) {
if (tag.getDouble("reload_time") == 55) { if (tag.getDouble("reload_time") == 55) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.SVD_RELOAD_NORMAL.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:svd_reload_normal player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == itemStack.getItem() if (player.getMainHandItem().getItem() == itemStack.getItem()

View file

@ -8,16 +8,14 @@ import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.item.AnimatedItem; import net.mcreator.target.item.AnimatedItem;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.mcreator.target.tools.TooltipTool; import net.mcreator.target.tools.TooltipTool;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -192,10 +190,8 @@ public class Taser extends GunItem implements GeoItem, AnimatedItem {
if (stack.getOrCreateTag().getDouble("reload_time") == 55) { if (stack.getOrCreateTag().getDouble("reload_time") == 55) {
player.getPersistentData().putDouble("id", id); player.getPersistentData().putDouble("id", id);
// TODO 修改音效播放 if (!player.level().isClientSide()) {
if (!player.level().isClientSide() && player.getServer() != null) { SoundTool.playLocalSound(player, TargetModSounds.TASER_RELOAD.get(), 100, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), player.level() instanceof ServerLevel ? (ServerLevel) player.level() : null, 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:taser_reload player @s ~ ~ ~ 100 1");
} }
} }
if (heldItem.getItem() == stack.getItem() && heldItem.getOrCreateTag().getDouble("id") == id) { if (heldItem.getItem() == stack.getItem() && heldItem.getOrCreateTag().getDouble("id") == id) {

View file

@ -13,12 +13,10 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer; import net.minecraft.client.renderer.BlockEntityWithoutLevelRenderer;
import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.Style; import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -175,9 +173,8 @@ public class Trachelium extends GunItem implements GeoItem, AnimatedItem {
if (itemTag.getBoolean("reloading")) { if (itemTag.getBoolean("reloading")) {
if (itemTag.getDouble("reload_time") == 57) { if (itemTag.getDouble("reload_time") == 57) {
entity.getPersistentData().putDouble("id", id); entity.getPersistentData().putDouble("id", id);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.TRACHELIUM_RELOAD.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:trachelium_reload player @s ~ ~ ~ 100 1");
} }
} }
if (mainHandItem.getItem() == itemstack.getItem() if (mainHandItem.getItem() == itemstack.getItem()

View file

@ -3,9 +3,11 @@ package net.mcreator.target.network.message;
import net.mcreator.target.entity.BocekArrowEntity; import net.mcreator.target.entity.BocekArrowEntity;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.procedures.PressFireProcedure; import net.mcreator.target.procedures.PressFireProcedure;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
@ -102,11 +104,9 @@ public class FireMessage {
level.addFreshEntity(arrow); level.addFreshEntity(arrow);
} }
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide()) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.BOCEK_ZOOM_FIRE_1P.get(), 10, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:bocek_zoom_fire_1p player @s ~ ~ ~ 10 1"); player.playSound(TargetModSounds.BOCEK_ZOOM_FIRE_3P.get(), 2, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:bocek_zoom_fire_3p player @a ~ ~ ~ 2 1");
} }
} else { } else {
for (int index0 = 0; index0 < 10; index0++) { for (int index0 = 0; index0 < 10; index0++) {
@ -114,10 +114,8 @@ public class FireMessage {
} }
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide() && player.getServer() != null) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.BOCEK_SHATTER_CAP_FIRE_1P.get(), 10, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:bocek_shatter_cap_fire_1p player @s ~ ~ ~ 10 1"); player.playSound(TargetModSounds.BOCEK_SHATTER_CAP_FIRE_3P.get(), 2, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:bocek_shatter_cap_fire_3p player @a ~ ~ ~ 2 1");
} }
} }

View file

@ -4,10 +4,13 @@ import net.mcreator.target.entity.GunGrenadeEntity;
import net.mcreator.target.init.TargetModAttributes; import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -57,15 +60,11 @@ public class M79fireProcedure {
} }
player.getCooldowns().addCooldown(usehand.getItem(), 15); player.getCooldowns().addCooldown(usehand.getItem(), 15);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.M_79_FIRE_1P.get(), 2, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_79_fire_1p player @s ~ ~ ~ 2 1"); SoundTool.playLocalSound(player, TargetModSounds.M_79_FIRE_3P.get(), 4, 1);
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.M_79_FAR.get(), 6, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_79_fire_3p player @a ~ ~ ~ 4 1"); SoundTool.playLocalSound(player, TargetModSounds.M_79_VERYFAR.get(), 12, 1);
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4,
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_79_far player @s ~ ~ ~ 6 1");
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4,
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_79_veryfar player @a ~ ~ ~ 12 1");
} }
usehand.getOrCreateTag().putInt("fire_animation", 2); usehand.getOrCreateTag().putInt("fire_animation", 2);
usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1)); usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1));

View file

@ -1,10 +1,9 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.minecraft.commands.CommandSource; import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -24,15 +23,11 @@ public class M870fireProcedure {
player.getCooldowns().addCooldown(usehand.getItem(), 13); player.getCooldowns().addCooldown(usehand.getItem(), 13);
usehand.getOrCreateTag().putDouble("firing", 13); usehand.getOrCreateTag().putDouble("firing", 13);
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide()) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.M_870_FIRE_1P.get(), 2, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:m_870_fire_1p player @s ~ ~ ~ 2 1"); SoundTool.playLocalSound(player, TargetModSounds.M_870_FIRE_3P.get(), 4, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.M_870_FAR.get(), 12, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:m_870_fire_3p player @a ~ ~ ~ 4 1"); SoundTool.playLocalSound(player, TargetModSounds.M_870_VERYFAR.get(), 24, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:m_870_far player @s ~ ~ ~ 12 1");
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:m_870_veryfar player @a ~ ~ ~ 24 1");
} }
usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1)); usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1));
usehand.getOrCreateTag().putInt("fire_animation", 2); usehand.getOrCreateTag().putInt("fire_animation", 2);

View file

@ -1,11 +1,10 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.GunsTool; import net.mcreator.target.tools.GunsTool;
import net.minecraft.commands.CommandSource; import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
@ -31,14 +30,10 @@ public class MarlinfireProcedure {
GunsTool.spawnBullet(player); GunsTool.spawnBullet(player);
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide() && player.getServer() != null) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FIRE_1P.get(), 2, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:marlin_fire_1p player @s ~ ~ ~ 2 1"); SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FIRE_3P.get(), 4, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.MARLIN_FAR.get(), 12, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:marlin_fire_3p player @a ~ ~ ~ 4 1"); SoundTool.playLocalSound(player, TargetModSounds.MARLIN_VERYFAR.get(), 24, 1);
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:marlin_far player @s ~ ~ ~ 12 1");
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4,
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:marlin_veryfar player @a ~ ~ ~ 24 1");
} }
usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1)); usehand.getOrCreateTag().putInt("ammo", (usehand.getOrCreateTag().getInt("ammo") - 1));
if (usehand.getOrCreateTag().getDouble("animindex") == 1) { if (usehand.getOrCreateTag().getDouble("animindex") == 1) {

View file

@ -1,11 +1,11 @@
package net.mcreator.target.procedures; package net.mcreator.target.procedures;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.CommandSource; import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth; import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource; import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
@ -315,9 +315,8 @@ public class PlayerReloadProcedure {
tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810))); tag.putDouble("id", (Mth.nextDouble(RandomSource.create(), 1, 1919810)));
player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5); player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 5);
tag.putDouble("prepare", 5); tag.putDouble("prepare", 5);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.MARLIN_START.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:marlin_start player @s ~ ~ ~ 100 1");
} }
} }
if (player.getMainHandItem().getItem() == TargetModItems.M_870.get() if (player.getMainHandItem().getItem() == TargetModItems.M_870.get()
@ -332,9 +331,8 @@ public class PlayerReloadProcedure {
player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 36); player.getCooldowns().addCooldown(player.getMainHandItem().getItem(), 36);
tag.putDouble("prepare", 36); tag.putDouble("prepare", 36);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.M_870_PREPARE_ALT.get(), 100, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:m_870_preparealt player @s ~ ~ ~ 100 1");
} }
} else { } else {
tag.putBoolean("reloading", true); tag.putBoolean("reloading", true);

View file

@ -2,11 +2,10 @@ package net.mcreator.target.procedures;
import net.mcreator.target.event.GunEventHandler; import net.mcreator.target.event.GunEventHandler;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.init.TargetModTags; import net.mcreator.target.init.TargetModTags;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.minecraft.commands.CommandSource; import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
public class PressFireProcedure { public class PressFireProcedure {
@ -28,9 +27,8 @@ public class PressFireProcedure {
&& !(mainHandItem.getItem() == TargetModItems.MINIGUN.get()) && !(mainHandItem.getItem() == TargetModItems.MINIGUN.get())
&& tag.getInt("ammo") == 0 && tag.getInt("ammo") == 0
&& !tag.getBoolean("reloading")) { && !tag.getBoolean("reloading")) {
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide()) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.TRIGGER_CLICK.get(), 10, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:triggerclick player @s ~ ~ ~ 10 1");
} }
} }
@ -38,9 +36,8 @@ public class PressFireProcedure {
player.getPersistentData().putDouble("mini_firing", 1); player.getPersistentData().putDouble("mini_firing", 1);
if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0) { if ((player.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).rifleAmmo == 0) {
if (!player.level().isClientSide() && player.getServer() != null) { if (!player.level().isClientSide()) {
player.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, player.position(), player.getRotationVector(), (ServerLevel) player.level(), 4, SoundTool.playLocalSound(player, TargetModSounds.TRIGGER_CLICK.get(), 10, 1);
player.getName().getString(), player.getDisplayName(), player.level().getServer(), player), "playsound target:triggerclick player @s ~ ~ ~ 10 1");
} }
} }
} }

View file

@ -4,10 +4,13 @@ import net.mcreator.target.entity.TaserBulletProjectileEntity;
import net.mcreator.target.init.TargetModAttributes; import net.mcreator.target.init.TargetModAttributes;
import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModEntities;
import net.mcreator.target.init.TargetModItems; import net.mcreator.target.init.TargetModItems;
import net.mcreator.target.init.TargetModSounds;
import net.mcreator.target.network.TargetModVariables; import net.mcreator.target.network.TargetModVariables;
import net.mcreator.target.tools.SoundTool;
import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSource;
import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.CommandSourceStack;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -32,15 +35,11 @@ public class TaserfireProcedure {
}); });
player.getCooldowns().addCooldown(usehand.getItem(), 5); player.getCooldowns().addCooldown(usehand.getItem(), 5);
if (!entity.level().isClientSide() && entity.getServer() != null) { if (entity instanceof ServerPlayer serverPlayer) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, SoundTool.playLocalSound(serverPlayer, TargetModSounds.TASER_FIRE_1P.get(), 1, 1);
entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "playsound target:taser_fire_1p player @s ~ ~ ~ 1 1"); serverPlayer.playSound(TargetModSounds.TASER_FIRE_3P.get(), 1, 1);
}
if (!entity.level().isClientSide() && entity.getServer() != null) { // TODO 重写stopsound
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "playsound target:taser_fire_3p player @a ~ ~ ~ 1 1");
}
if (!entity.level().isClientSide() && entity.getServer() != null) {
entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4, entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), entity.level() instanceof ServerLevel ? (ServerLevel) entity.level() : null, 4,
entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:taser_fire_3p"); entity.getName().getString(), entity.getDisplayName(), entity.level().getServer(), entity), "stopsound @s player target:taser_fire_3p");
} }