package net.mcreator.target.procedures; import net.mcreator.target.init.TargetModItems; import net.mcreator.target.network.TargetModVariables; import net.minecraft.commands.CommandSource; import net.minecraft.commands.CommandSourceStack; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.InteractionHand; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; public class ShotgunAmmoBoxWanJiaWanChengShiYongWuPinShiProcedure { public static void execute(Entity entity, ItemStack itemstack) { if (entity == null) return; if (entity instanceof Player _player) _player.getCooldowns().addCooldown(itemstack.getItem(), 20); if (entity instanceof LivingEntity _entity) _entity.swing(InteractionHand.MAIN_HAND, true); if (entity instanceof Player _player) { ItemStack _stktoremove = new ItemStack(TargetModItems.SHOTGUN_AMMO_BOX.get()); _player.getInventory().clearOrCountMatchingItems(p -> _stktoremove.getItem() == p.getItem(), 1, _player.inventoryMenu.getCraftSlots()); } { double _setval = (entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).orElse(new TargetModVariables.PlayerVariables())).shotgunAmmo + 12; entity.getCapability(TargetModVariables.PLAYER_VARIABLES_CAPABILITY, null).ifPresent(capability -> { capability.shotgunAmmo = _setval; capability.syncPlayerVariables(entity); }); } if (entity instanceof Player _player && !_player.level().isClientSide()) _player.displayClientMessage(Component.literal("Shotgun Ammo +12"), false); { Entity _ent = entity; if (!_ent.level().isClientSide() && _ent.getServer() != null) { _ent.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, _ent.position(), _ent.getRotationVector(), _ent.level() instanceof ServerLevel ? (ServerLevel) _ent.level() : null, 4, _ent.getName().getString(), _ent.getDisplayName(), _ent.level().getServer(), _ent), "playsound target:bulletsupply voice @a ~ ~ ~ 1 1"); } } } }